Skip to content

HTTP keep-alive

HTTP keep-alive

Persistent connections via HTTP are possible with the Connection: keep-alive header.

In normal HTTP requests, without keep-alive, the server closes the TCP connection once the response has been sent to the client. One request and one response equal one connection.

With keep-alive, one connection can be used to handle multiple requests. The server does not close the connection after sending the response, but instead awaits more connections. The connection can be set to terminate after a specific number of connections have been made or after an idle timeout. These settings can be made on the Keep-Alive general header.

Benefits:

Because of the performance benefits of keep-alive, these persistent connections are often used to facilitate HTTPS (Secure Socket Layer) connections, which are rather expensive compared to HTTP in terms of resources.