{{HTTPSidebar}}{{Non-standard_header}}
The Keep-Alive
general header allows the sender to hint about how the connection may be used by setting a timeout and a max amount of requests.
The {{HTTPHeader("Connection")}} header needs to be set to "keep-alive" for this header to have any meaning. Also, {{HTTPHeader("Connection")}} and {{HTTPHeader("Keep-Alive")}} are ignored in HTTP/2; connection management is handled there by other mechanisms.
Header type | {{Glossary("General header")}} |
---|---|
{{Glossary("Forbidden header name")}} | no |
Syntax
Keep-Alive: parameters
Directives
timeout
indicating the minimum amount of time an idele connection has to be kept opened (in seconds). Note that timeouts longer than the TCP timeout may be ignored if no keep-alive TCP message is set at the transport level.max
indicating the maximum amount of requests that can be send on this connection before closing it. Unless0
, this value is ignored for non-pipelined connection as another request will be send in the next response. HTTP pipeline can use it to limit the amount of pipelining done.
- parameters
- A comma-separated list of parameters, each consisting in a identifer and a value separated by the equal sign (
'='
). The following identifier are possible:
Examples
A response containing a Keep-Alive
header:
HTTP/1.1 200 OK Connection: Keep-Alive Content-Encoding: gzip Content-Type: text/html; charset=utf-8 Date: Thu, 11 Aug 2016 15:23:13 GMT Keep-Alive: timeout=5, max=1000 Last-Modified: Mon, 25 Jul 2016 04:32:39 GMT Server: Apache (body)
Specifications
Specification | Title |
---|---|
HyperText Transport Protocol Keep-Alive Header | The Keep-Alive Header (Experimental specification) |
{{RFC("7230", "Keep-Alive", "appendix-A.1.2")}} | Hypertext Transfer Protocol (HTTP/1.1): Message Syntax and Routing |
Browser compatibility
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/README.md and send us a pull request
{{Compat}}
See also
- {{HTTPHeader("Connection")}}
- Connection management in HTTP/1.x