• Post Reply Bookmark Topic Watch Topic
  • New Topic

Who is responsible for setting HTTP Connection header?

 
Alex Rebrov
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I use Tomcat and Google Chrome, and I wonder, in this copula who is responsible for setting and processing HTTP Connection: close or keep-alive. How can I configure Tomcat 8.0.x to close connection immediately? Can we keep it forever? I presume that 'keep-alive' is for optimization purposes, so when we should use 'close'?
 
Tim Holloway
Bartender
Posts: 18415
58
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The client (which would be Chrome) connects to the server. A reply-port is opened on the client for the server to send the HTTP response to.

In the original HTTP concept, a connection would be opened, the request would be sent, the reply received and the connection would be closed.

Getting a connection, setting up network routes, etc. is relatively expensive, but HTTP doesn't allow for a continuous connection. So a compromise was reached: the "keep-alive" connection. This is a transparent mechanism that avoids the extra overhead when making repeated requests over a short period of time. The client still behaves like each connection is made from scratch, but the network knows better.

There are only a limited number of connections available, so the keep-alive interval is fairly short. The exact duration is usually configurable, but varies with the brand and version of the client.

In most cases, it's best to leave the default settings in place.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!