What does the keep alive header do

This is part of the Semicolon&Sons Code Diary - consisting of lessons learned on the job. You're in the web-development category.

Last Updated: 2024-11-21

Under HTTP 1.0, connections are not considered persistent unless a keep-alive header is included.

Connection: keep-alive

However, in HTTP 1.1, all connections are considered persistent unless declared otherwise.

With keep-alive, 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.

The default connection timeout of Apache httpd 2.0 is as little as 15 seconds and just 5 seconds for Apache httpd 2.2 and above. This stops too many server processes being used.

Pros and cons

Advantages:

Disadvantages:

Resources