What is Connection Keep-alive?

Posted on

Question :

When I check the headers I am sending to a php page, which is installed locally, I always see this Connection: Keep-Alive




array (size=7)
  'Host' => string '' (length=9)
  'User-Agent' => string 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:39.0) Gecko/20100101 Firefox/39.0' (length=76)
  'Accept' => string 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8' (length=63)
  'Accept-Language' => string 'pt-BR,pt;q=0.8,en-US;q=0.5,en;q=0.3' (length=35)
  'Accept-Encoding' => string 'gzip, deflate' (length=13)
  'Cookie' => string '_ga=GA1.1.1775431020.1436189521' (length=31)

  'Connection' => string 'keep-alive' (length=10)
  • What does Keep-alive mean?
  • What is it for?

Answer :

A Keep-Alive connection means a persistent connection, or a persistent life connection, between the client and the server. Preventing the connection from breaking intermittently.

The HTTP default connection is usually closed after each request has been completed, which means that the server closes the TCP connection upon delivery of the response.
In order to keep the connection open for multiple requests, the keep-alive connection header can be used.

It’s clear how keep alive works.


  • Increaseswebsitespeed:ReducedlatencyinHTTPtransfers.
  • ReduceCPUusage:Considerthatthewebsitehasmultipleimages,files,aconnectionisrequiredforeachfile,increasingtheuseofCPU,usingkeep-alive,onlyaconnectionismade,soreducingtheuseofCPU.


  • Increasesmemoryusage:EnablingKeepAliveincreasesmemoryusageontheserver.Apacheprocesseshavetokeepopenconnectionswaitingfornewrequestsforestablishedconnections.


< a href=”https://www.maxcdn.com/one/visual-glossary/keep-alive/”> MaxCDN


Keep-alive allows the client and server to maintain a persistent connection during HTTP protocol communication. For example, let’s imagine the client sending a GET request to a page that is on the server. This page can contain several image files, javascript, php, css. Instead of the moment the request occurs, the server delivers a file, closes the connection, and opens another, a persistent connection is maintained between the server and the client, which only terminates after the delivery of all files. >



Leave a Reply

Your email address will not be published. Required fields are marked *