W3cubDocs

/HTTP

Keep-Alive

Non-standard
This feature is non-standard and is not on a standards track. Do not use it on production sites facing the Web: it will not work for every user. There may also be large incompatibilities between implementations and the behavior may change in the future.

The Keep-Alive general header allows the sender to hint about how the connection and may be used to set a timeout and a maximum amount of requests.

The Connection header needs to be set to "keep-alive" for this header to have any meaning. Also, Connection and Keep-Alive are ignored in HTTP/2; connection management is handled by other mechanisms there.

Header type General header
Forbidden header name no

Syntax

Keep-Alive: parameters

Directives

parameters
A comma-separated list of parameters, each consisting of an identifier and a value separated by the equal sign ('='). The following identifiers are possible:
  • timeout: indicating the minimum amount of time an idle 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 sent on this connection before closing it. Unless 0, this value is ignored for non-pipelined connections as another request will be send in the next response. An HTTP pipeline can use it to limit the pipelining.

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, section appendix-A.1.2: Keep-Alive Hypertext Transfer Protocol (HTTP/1.1): Message Syntax and Routing

Browser compatibility

Feature Chrome Edge Firefox Internet Explorer Opera Safari Servo
Keep-Alive (Yes) (Yes) (Yes) (Yes) (Yes) (Yes) (Yes)
Feature Android Chrome for Android Edge Mobile Firefox for Android IE Mobile Opera Mobile Safari Mobile
Keep-Alive (Yes) (Yes) (Yes) (Yes) (Yes) (Yes) (Yes)

See also

© 2005–2017 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Keep-Alive