Keep-Alive - HTTP 编辑
The Keep-Alive
general header allows the sender to hint about how the connection 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.
Connection-specific header fields such as Connection
and 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.
Header type | General header |
---|---|
Forbidden header name | yes |
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 number of requests that can be sent on this connection before closing it. Unless0
, this value is ignored for non-pipelined connections as another request will be sent 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 |
---|---|
HTTP Keep-Alive Header | Keep-Alive Header (IETF Internet Draft) |
RFC 7230, appendix A.1.2: Keep-Alive | Hypertext Transfer Protocol (HTTP/1.1): Message Syntax and Routing |
Browser compatibility
BCD tables only load in the browser
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.
See also
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论