--- title: Connection slug: Web/HTTP/Headers/Connection translation_of: Web/HTTP/Headers/Connection ---
The Connection
general header controls whether or not the network connection stays open after the current transaction finishes. If the value sent is keep-alive
, the connection is persistent and not closed, allowing for subsequent requests to the same server to be done.
Connection-specific header fields such as {{HTTPHeader("Connection")}} and {{HTTPHeader("Keep-Alive")}} are prohibited in HTTP/2. Chrome and Firefox ignore them in HTTP/2 responses, but Safari conforms to the HTTP/2 spec requirements and won’t load any response which contains them.
Except for the standard hop-by-hop headers ({{HTTPHeader("Keep-Alive")}}, {{HTTPHeader("Transfer-Encoding")}}, {{HTTPHeader("TE")}}, {{HTTPHeader("Connection")}}, {{HTTPHeader("Trailer")}}, {{HTTPHeader("Upgrade")}}, {{HTTPHeader("Proxy-Authorization")}} and {{HTTPHeader("Proxy-Authenticate")}}), any hop-by-hop headers used by the message must be listed in the Connection
header, so that the first proxy knows it has to consume them and not forward them further. Standard hop-by-hop headers can be listed too (it is often the case of {{HTTPHeader("Keep-Alive")}}, but this is not mandatory).
Header type | {{Glossary("General header")}} |
---|---|
{{Glossary("Forbidden header name")}} | yes |
Connection: keep-alive Connection: close
close
keep-alive
only]The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
{{Compat("http.headers.Connection")}}