What is a Keep-Alive? How is it implemented differently in HTTP 1.0 and HTTP 1.1?

Govind Seshadri

Http operates on what is called the request/response paradigm. The client application generates a request for information which is passed to the server, which then replies to it. In the earliest implementation of HTTP, each request created a new socket connection to the server, sent the command, then read the response from the same connection. Although this was simple to specify and implement, it was also slow, especially in a high volume situation.

Keep-alives were added to HTTP to basically reduce the significant overhead of rapidly creating and closing socket connections for each new request. The following is a summary of how it works within HTTP 1.0 and 1.1:

HTTP 1.0
The HTTP 1.0 specification does not really delve into how Keep-Alive should work. Basically, browsers that support Keep-Alive appends an additional header to the request as:

Connection: Keep-Alive
When the server processes the request and generates a response, it also adds a header to the response:
Connection: Keep-Alive
When this is done, the socket connection is not closed as before, but kept open after sending the response. When the client sends another request, it reuses the same connection. The connection will continue to be reused until either the client or the server decides that the conversation is over, and one of them drops the connection.

HTTP 1.1
Under HTTP 1.1, Keep-Alive is implemented differently. All connections, by default, are kept open, unless stated otherwise with the following header:

Connection: close
About | Sitemap | Contact