Movatterモバイル変換


[0]ホーム

URL:


  1. Web
  2. HTTP
  3. Reference
  4. Headers
  5. Keep-Alive

Keep-Alive header

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since ⁨July 2015⁩.

The HTTPKeep-Aliverequest andresponse header allows the sender to hint how a connection may be used in terms of a timeout and a maximum amount of requests.

Note:ForKeep-Alive to have any effect, the message must also include aConnection: 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 aConnection: keep-alive request header.Additional parameters for the connection can be requested with theKeep-Alive header.

Warning:Connection-specific header fields such asConnection andKeep-Alive are prohibited inHTTP/2 andHTTP/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 typeRequest header,Response header
Forbidden request headerYes

Syntax

http
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

An integer that is the time in seconds that the host will allow an idle connection to remain open before it is closed.A connection is idle if no data is sent or received by a host. A host may keep an idle connection open for longer thantimeout seconds, but the host should attempt to retain a connection for at leasttimeout seconds.

max

An integer that is 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 aKeep-Alive header:

http
HTTP/1.1 200 OKConnection: Keep-AliveContent-Encoding: gzipContent-Type: text/html; charset=utf-8Date: Thu, 11 Aug 2016 15:23:13 GMTKeep-Alive: timeout=5, max=200Last-Modified: Mon, 25 Jul 2016 04:32:39 GMTServer: Apache(body)

Specifications

Specification
HTTP/1.1
# compatibility.with.http.1.0.persistent.connections

Browser compatibility

See also

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp