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 1106805 of Accept-Encoding

  • Revision slug: Web/HTTP/Headers/Accept-Encoding
  • Revision title: Accept-Encoding
  • Revision id: 1106805
  • Created:
  • Creator: teoli
  • Is current revision? No
  • Comment

Revision Content

{{HTTPSidebar}}

The Accept-Encoding request HTTP header advertizes which content encoding, usually a compression algorithm, the client is able to understand. Using content negotiation, the server then selects one of the proposal, use it and inform the client of its choice with the {{HTTPHeader("Content-Encoding")}} response header.

Header type {{Glossary("Request header")}}
{{Glossary("Forbidden header name")}} no

Syntax

Accept-Encoding: <content_encoding>
Accept-Encoding: <content_encoding>, <content_encoding>

Directives

<content_encoding>
A list of content encoding algorithms, usually compression algorithms. Their order of preference is expressed using relative quality factor called the weight. The possible algorithms are:
Algorithm Description
gzip A compression format using the Lempel-Ziv coding (LZ77), with a 32-bit CRC.
compress A compression format using the Lempel-Ziv-Welch (LZW) algorithm.
deflate A compression format using the zlib structure, with the deflate compression algorithm.
br A compression format using the Brotli algorithm.
identity Indicates the identity function (i.e. no compression, nor modification).  This is the default value if the header is not present.
* Matches any content encoding not already listed in the header

Examples

Accept-Encoding: gzip

Accept-Encoding: gzip, compress, br

Accept-Encoding: br;q=1.0, gzip;q=0.8, *;q=0.1

Specifications

Specification Title
{{RFC("7232", "Accept-Encoding", "5.3.4")}} Hypertext Transfer Protocol (HTTP/1.1): Semantics and Context

Browser compatibility

{{Compat}}

See also

  • HTTP content negotiation
  • Header with the result of the content negotiation: {{HTTPHeader("Content-Encoding")}}
  • Other similar headers: {{HTTPHeader("TE")}}, {{HTTPHeader("Accept")}}, {{HTTPHeader("Accept-Charset")}}, {{HTTPHeader("Accept-Language")}}

Revision Source

<div>{{HTTPSidebar}}</div>

<p>The <strong><code>Accept-Encoding</code></strong> request HTTP header advertizes which content encoding, usually a compression algorithm, the client is able to understand. Using <a href="/en-US/docs/Web/HTTP/Content_negotiation">content negotiation</a>, the server then selects one of the proposal, use it and inform the client of its choice with the {{HTTPHeader("Content-Encoding")}} response header.</p>

<table class="properties">
 <tbody>
  <tr>
   <th scope="row">Header type</th>
   <td>{{Glossary("Request 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">
Accept-Encoding: &lt;content_encoding&gt;
Accept-Encoding: &lt;content_encoding&gt;, &lt;content_encoding&gt;</pre>

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

<dl>
 <dt>&lt;content_encoding&gt;</dt>
 <dd>A list of content encoding algorithms, usually compression algorithms. Their order of preference is expressed using relative <a href="/en-US/docs/Glossary/Q-factor">quality factor</a> called the <em>weight</em>. The possible algorithms are:
 <table class="standard-table">
  <thead>
   <tr>
    <th scope="col">Algorithm</th>
    <th scope="col">Description</th>
   </tr>
  </thead>
  <tbody>
   <tr>
    <td><code>gzip</code></td>
    <td>A compression format using the <a class="external external-icon" href="https://en.wikipedia.org/wiki/LZ77_and_LZ78#LZ77">Lempel-Ziv coding</a> (LZ77), with a 32-bit CRC.</td>
   </tr>
   <tr>
    <td><code>compress</code></td>
    <td>A compression format using the <a class="external external-icon" href="https://en.wikipedia.org/wiki/LZW">Lempel-Ziv-Welch</a> (LZW) algorithm.</td>
   </tr>
   <tr>
    <td><code>deflate</code></td>
    <td>A compression format using the <a class="external external-icon" href="https://en.wikipedia.org/wiki/Zlib">zlib</a> structure, with the <a class="external external-icon" href="https://en.wikipedia.org/wiki/DEFLATE"><em>deflate</em></a> compression algorithm.</td>
   </tr>
   <tr>
    <td><code>br</code></td>
    <td>A compression format using the <a class="external external-icon" href="https://en.wikipedia.org/wiki/Brotli">Brotli</a> algorithm.</td>
   </tr>
   <tr>
    <td><code>identity</code></td>
    <td>Indicates the identity function (i.e. no compression, nor modification).&nbsp; This is the default value if the header is not present.</td>
   </tr>
   <tr>
    <td><code>*</code></td>
    <td>Matches any content encoding not already listed in the header</td>
   </tr>
  </tbody>
 </table>
 </dd>
</dl>

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

<pre>
Accept-Encoding: gzip

Accept-Encoding: gzip, compress, br

Accept-Encoding: br;q=1.0, gzip;q=0.8, *;q=0.1
</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>{{RFC("7232", "Accept-Encoding", "5.3.4")}}</td>
   <td>Hypertext Transfer Protocol (HTTP/1.1): Semantics and Context</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>HTTP <a href="/en-US/docs/Web/HTTP/Content_negotiation">content negotiation</a></li>
 <li>Header with the result of the content negotiation: {{HTTPHeader("Content-Encoding")}}</li>
 <li>Other similar headers: {{HTTPHeader("TE")}}, {{HTTPHeader("Accept")}}, {{HTTPHeader("Accept-Charset")}}, {{HTTPHeader("Accept-Language")}}</li>
</ul>
Revert to this revision