Concepts / The web

The web

HTTP keep-alive

Also called persistent connection, Connection: close, connection reuse

Several HTTP requests over one TCP connection instead of a new handshake for each.

One handshake for many requests
One handshake for many requests

Without keep-alive every request opens a new connection and pays a handshake first. With it the connection stays open and the later requests go straight out.

HTTP keep-alive means sending several requests over one TCP connection instead of opening a new one for each. HTTP/1.1 keeps the connection open by default, so the next request skips the TCP handshake and, over HTTPS, the TLS one. The client finds where each response ends from its Content-Length or chunked encoding. Connection: close asks the server to hang up after answering. The server closes idle connections after a timeout.

See it on real machines

Read next

Learn it on real machines.

Every lab is a small network of real Linux machines in your browser. Sign in with Google or email to start.

Start this lab