Connection

The HTTP Connection header is used to control whether an active connection stays in place after a transaction is complete.

Usage

The HTTP Connection header dictates whether the network connection remains open after the current transaction. There are two directives: keep-alive and close.

keep-alive

The keep-alive directive indicates that the client wants the HTTP Connection to persist and remain open after the current transaction is complete. This is the default setting for HTTP/1.1 requests.

Connection: keep-alive

close

The close directive signals that the client wants to close the HTTP Connection, post-transaction. This is the default setting for HTTP/1.0 requests.

Connection: close

Note

As of HTTP/2, the HTTP Connection header is no longer valid. Some browser implementations ignore the HTTP header whereas others will reject messages that contain it.

Takeaway

In earlier implementations of HTTP, the HTTP Connection header was used to control what happened to the HTTP connection after the current transaction was complete. As of HTTP/2, it is no longer used.

See also

Last updated: June 2, 2022