How HTTP persistent connection between browser and server work ?

The Keep-alive is deprecated in Http 1.1 specification, but it is still commonly used by browsers and servers. Clients implementing HTTP/1.0 keep-alive connection can request that a connection be kept open by including the Connection: Keep-Alive request header. If the server is willing to keep the connection open for the next request, it will respond with the same header in the response. If there is no Connection: Keep-Alive header in the response, the client assumes that the server does not support keep-alive and that the server will close the connection when the response message is sent back.

Keep-Alive header must be sent with all messages that want to continue the persistent If the client does not send a Connection: Keep-Alive header the server will close the connection after that request. Same thing if the response does not have Connection: Keep-Alive header browser will assume that server has closed the connection.

The browsers make use of connection close signal even to figure out end of message body. So if you want the connection to remain open, you will have to set correct value for Content-Length, also set correct Content Type header set or the message should be encoded with the chuncked transfer encoding.

The keep-alive behavior can be tuned by following comma-separated options specified in the Keep-Alive general header

  1. The timeout parameter is sent in a Keep-Alive response header. It estimates how long the server is likely to keep the connection alive for.

  2. The max parameter is sent in a Keep-Alive response header. It estimates how many more HTTP transactions the server is likely to keep the connection alive for.

  3. The Keep-Alive header also supports arbitrary unprocessed attributes, primarily for diagnostic and debugging purpose.


The Keep-Alive header is completely option but is permitted only when Connection:Keep-Alive header is present.

Connection: Keep-Alive
Keep-Alive: max=100, timeout=300


These headers in response, will tell browser that server will keep this connection open for next 100 resource request and if you don't make request it will timeout in 300 seconds

3 comments:

srjwebsolutions said...

We are leading responsive website designing and development company in Noida.
We are offering mobile friendly responsive website designing, website development, e-commerce website, seo service and sem services in Noida.

Responsive Website Designing Company in Noida
Website Designing Company in Noida
SEO Services in Noida
SMO Services in Noida

Vikas Chaudhary said...

Battery Mantra is Authorized exide car battery dealer in Noida and Greater Noida. We are providing our service in Indirapuram, Delhi, Ashok Nagar.

Exide Battery Dealer in Noida
Battery Dealer in Noida
Authorized Battery Dealer in Noida
Car Battery Dealer in Noida
Car Battery Dealer
Exide Battery Dealer

EG MEDI said...

Egmedi.com is online medical store pharmacy in laxmi nagar Delhi. You can Order prescription/OTC medicines online.
Cash on Delivery available. Free Home Delivery


Online Pharmacy in Delhi
Buy Online medicine in Delhi
Online Pharmacy in laxmi nagar
Buy Online medicine in laxmi nagar
Onine Medical Store in Delhi
Online Medical store in laxmi nagar
Online medicine store in delhi
online medicine store in laxmi nagar
Purchase Medicine Online
Online Pharmacy India
Online Medical Store