Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

Revision 1104219 of Keep-Alive

  • Revision slug: Web/HTTP/Headers/Keep-Alive
  • Revision title: Keep-Alive
  • Revision id: 1104219
  • Created:
  • Creator: fscholz
  • Is current revision? No
  • Comment review

Revision Content

{{HTTPSidebar}}{{Non-standard_header}}

The Keep-Alive general header allows the sender to hint about how the connection and may be used by setting a timeout and a maximum 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 by other mechanisms there.

Header type {{Glossary("General header")}}
{{Glossary("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", "Keep-Alive", "appendix-A.1.2")}} Hypertext Transfer Protocol (HTTP/1.1): Message Syntax and Routing

Browser compatibility

{{Compat}}

See also

Revision Source

<div>{{HTTPSidebar}}{{Non-standard_header}}</div>

<p>The <code><strong>Keep-Alive</strong></code> general header allows the sender to hint about how the connection and may be used by setting a timeout and a maximum amount of requests.</p>

<div class="note">
<p>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 by other mechanisms there.</p>
</div>

<table class="properties">
 <tbody>
  <tr>
   <th scope="row">Header type</th>
   <td>{{Glossary("General header")}}</td>
  </tr>
  <tr>
   <th scope="row">{{Glossary("Forbidden header name")}}</th>
   <td>no</td>
  </tr>
 </tbody>
</table>

<h2 id="Syntax">Syntax</h2>

<pre class="syntaxbox">
Keep-Alive: <em>parameters</em></pre>

<h2 id="Directives">Directives</h2>

<dl>
 <dt><em>parameters</em></dt>
 <dd>A comma-separated list of parameters, each consisting of an identifier and a value separated by the equal sign (<code>'='</code>). The following identifiers are possible:
 <ul>
  <li><code>timeout</code>: indicating the <em>minimum </em>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.</li>
  <li><code>max</code>: indicating the maximum amount of requests that can be sent on this connection before closing it. Unless <code>0</code>, 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.</li>
 </ul>
 </dd>
</dl>

<h2 id="Examples">Examples</h2>

<p>A response containing a <code>Keep-Alive</code> header:</p>

<pre>
HTTP/1.1 200 OK
<strong>Connection: Keep-Alive</strong>
Content-Encoding: gzip
Content-Type: text/html; charset=utf-8
Date: Thu, 11 Aug 2016 15:23:13 GMT
<strong>Keep-Alive: timeout=5, max=1000</strong>
Last-Modified: Mon, 25 Jul 2016 04:32:39 GMT
Server: Apache

(body)</pre>

<h2 id="Specifications">Specifications</h2>

<table class="standard-table">
 <tbody>
  <tr>
   <th scope="col">Specification</th>
   <th scope="col">Title</th>
  </tr>
  <tr>
   <td><a href="https://tools.ietf.org/id/draft-thomson-hybi-http-timeout-01.html#rfc.section.2">HyperText Transport Protocol Keep-Alive Header</a></td>
   <td>The Keep-Alive Header (Experimental specification)</td>
  </tr>
  <tr>
   <td>{{RFC("7230", "Keep-Alive", "appendix-A.1.2")}}</td>
   <td>Hypertext Transfer Protocol (HTTP/1.1): Message Syntax and Routing</td>
  </tr>
 </tbody>
</table>

<h2 id="Browser_compatibility">Browser compatibility</h2>

<p class="hidden">The compatibility table in this page is generated from structured data. If you’d like to contribute to the data, please check out <a href="https://github.com/mdn/browser-compat-data/README.md">https://github.com/mdn/browser-compat-data/README.md</a> and send us a pull request</p>

<p>{{Compat}}</p>

<h2 id="See_also">See also</h2>

<ul>
 <li>{{HTTPHeader("Connection")}}</li>
 <li><a href="/en-US/docs/Web/HTTP/Connection_management_in_HTTP_1.x">Connection management in HTTP/1.x</a></li>
</ul>
Revert to this revision