What is a Keep-Alive? How is it implemented differently in HTTP 1.0 and HTTP 1.1?
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:
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:
When the server processes the request and generates a response, it also adds a header to the response:
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.
Under HTTP 1.1, Keep-Alive is implemented differently. All connections, by default, are kept open, unless stated otherwise with the following header: