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.
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.
- save time by reducing cumulative latency from initiating and closing connections
- reduce CPU/memory usage
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.