Connection

These headers control (or give information about) the HTTP connection.

Response headers

Connection

Close the TCP connection after the current transaction (HTTP/1.0) or keep it alive (default in HTTP/1.1, the current standard).

Connection: close
Connection: keep-alive

Keep-Alive

Controls (1) how long the connection should be open and (2) what is the maximum amount of requests before it is closed. (Requires Connection: keep-alive.)

  • timeout=<idle-seconds> how long (in seconds) the host should allow an idle connection to remain open before it's closed
  • max=<number> the maximum number of requests that can be sent on this connection before it's closed
Keep-Alive: timeout=5
Keep-Alive: timeout=5, max=1000

Transfer-Encoding

Specifies the form of encoding used to transfer the payload body between two server nodes (to form the new "response body" that will be sent). If more than one encoding is used, they are separated with commas, e.g. Transfer-Encoding: gzip, chunked.

Not to be confused with Content-Encoding, which is an end-to-end encoding (the encoding is used throughout the whole connection).

Transfer-Encoding: chunked
Transfer-Encoding: compress
Transfer-Encoding: deflate
Transfer-Encoding: gzip
Transfer-Encoding: identity

References