Keep-Alive header


目录

The HTTP Keep-Alive request and response header allows the sender to hint how a connection may be used in terms of a timeout and a maximum number of requests.

NOTE: For Keep-Alive to have any effect, the message must also include a Connection: keep-alive header.

HTTP/1.0 closes the connection after each request/response interaction by default, so persistent connections in HTTP/1.0 must be explicitly negotiated. Some clients and servers might wish to be compatible with previous approaches to persistent connections, and can do this with a Connection: keep-alive request header. Additional parameters for the connection can be requested with the Keep-Alive header.

WARNING: Connection-specific header fields such as Connection and Keep-Alive are prohibited in HTTP/2 and HTTP/3. Chrome and Firefox ignore them in HTTP/2 responses, but Safari conforms to the HTTP/2 specification requirements and does not load any response that contains them.

Header type [Request header](https://developer.mozilla.org/en-US/docs/Glossary/Request%20header), [Response header](https://developer.mozilla.org/en-US/docs/Glossary/Response%20header)
[Forbidden request header](https://developer.mozilla.org/en-US/docs/Glossary/Forbidden%20request%20header) Yes

Syntax

Keep-Alive: <parameters>

Directives

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=200
Last-Modified: Mon, 25 Jul 2016 04:32:39 GMT
Server: Apache

(body)

Specifications

Browser compatibility

See also


版本号 #3
由 壳壳虫 创建于 2026-10-31 03:27:53 UTC
由 cocobook-sync 更新于 2026-11-04 17:35:49 UTC