HTTP persistent connection

HTTP persistent connection, also called HTTP keep-alive, or HTTP connection reuse, is the idea of using a single TCP connection to send and receive multiple HTTP requests/responses, as opposed to opening a new connection for every single request/response pair. The newer HTTP/2 protocol uses the same idea and takes it further to allow multiple concurrent requests/responses to be multiplexed over a single connection.


HTTP 1.0

Under HTTP 1.0, there is no official specification for how keepalive operates. It was, in essence, added to an existing protocol. If the client supports keep-alive, it adds an additional header to the request:

Connection: keep-alive

Then, when the server receives this request and generates a response, it also adds a header to the response:

Connection: keep-alive

Following this, the connection is not dropped, but is instead kept open. When the client sends another request, it uses the same connection. This will continue until either the client or the server decides that the conversation is over, and one of them drops the connection.

HTTP 1.1

In HTTP 1.1, all connections are considered persistent unless declared otherwise.[1] The HTTP persistent connections do not use separate keepalive messages, they just allow multiple requests to use a single connection. However, the default connection timeout of Apache httpd 1.3 and 2.0 is as little as 15 seconds[2][3] and just 5 seconds for Apache httpd 2.2 and above.[4][5] The advantage of a short timeout is the ability to deliver multiple components of a web page quickly while not consuming resources to run multiple server processes or threads for too long.[6]


These advantages are even more important for secure HTTPS connections, because establishing a secure connection needs much more CPU time and network round-trips.

According to RFC 7230, section 6.4, "a client ought to limit the number of simultaneous open connections that it maintains to a given server". The previous version of the HTTP/1.1 specification stated specific maximum values but in the words of RFC 7230 "this was found to be impractical for many applications... instead... be conservative when opening multiple connections". These guidelines are intended to improve HTTP response times and avoid congestion. If HTTP pipelining is correctly implemented, there is no performance benefit to be gained from additional connections, while additional connections may cause issues with congestion.[7]


If the client does not close the connection when all of the data it needs has been received, the resources needed to keep the connection open on the server will be unavailable for other clients. How much this affects the server's availability and how long the resources are unavailable depend on the server's architecture and configuration.

Use in web browsers

Schema of multiple vs. persistent connection.

All modern web browsers use persistent connections, including Google Chrome, Firefox, Internet Explorer (since 4.01), Opera (since 4.0)[8] and Safari.

By default, Internet Explorer versions 6 and 7 use two persistent connections while version 8 uses six.[9] Persistent connections time out after 60 seconds of inactivity which is changeable via the Windows Registry.[10]

In Firefox, the number of simultaneous connections can be customized (per-server, per-proxy, total). Persistent connections time out after 115 seconds (1.92 minutes) of inactivity which is changeable via the configuration.[11]


  1. Hypertext Transfer Protocol (HTTP/1.1): Message Syntax and Routing, Persistence
  2. Apache HTTP Server 1.3 – KeepAliveTimeout Directive
  3. Apache HTTP Server 2.0 – KeepAliveTimeout Directive
  4. Apache HTTP Server 2.2 – KeepAliveTimeout Directive
  5. Apache HTTP Server 2.4 – KeepAliveTimeout Directive
  6. Multiple (wiki). "Httpd/KeepAlive". Docforge. Archived from the original on January 6, 2010. Retrieved 2010-01-30.
  7. Nielssen, Frystyk Henryk; Gettys, James; Baird-Smith, Anselm; Prud’hommeaux, Eric; Wium Lie, Håkon; Lilley, Chris (October 1997), "Network Performance Effects of HTTP/1.1, CSS1, and PNG", Computer Communication Review, 27 (4), ISSN 0146-4833
  8. "Opera 4.0 Upgrades File Exchange: Includes HTTP 1.1". Opera Software. 2000-03-28. Retrieved 2009-07-08.
  9. "IE8 speeds things up". 2008-03-10. Retrieved 2009-07-17.
  10. "How to change the default keep-alive time-out value in Internet Explorer". Microsoft. 2007-10-27. Retrieved 2009-07-17.
  11. "Network.http.keep-alive.timeout". Retrieved 2009-07-17.

External links

This article is issued from Wikipedia - version of the 10/9/2016. The text is available under the Creative Commons Attribution/Share Alike but additional terms may apply for the media files.