Revision 1088717 of Content-Encoding

  • Revision slug: Web/HTTP/Headers/Content-Encoding
  • Revision title: Content-Encoding
  • Revision id: 1088717
  • Created:
  • Creator: fscholz
  • Is current revision? No
  • Comment update

Revision Content

{{HTTPSidebar}}

The Content-Encoding header indicates which algorithm is used for the message.

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

Syntax

Content-Encoding: gzip
Content-Encoding: compress
Content-Encoding: deflate
Content-Encoding: identity
Content-Encoding: br

Directives

gzip
A format using the Lempel-Ziv coding (LZ77), with a 32-bit CRC. This is originally the format of the UNIX gzip program. The HTTP/1.1 standard also recommends that the servers supporting this content-encoding should recognize x-gzip as an alias, for compatibility purposes.
compress
A format using the Lempel-Ziv-Welch (LZW) algorithm. The value name was taken from the UNIX compress program, which implemented this algorithm.
Like the compress program, which has disappeared from most UNIX distributions, this content-encoding is used by almost no browsers today, partly because of a patent issue (which expired in 2003).
deflate
Using the zlib structure (defined in RFC 1950), with the deflate compression algorithm (defined in RFC 1951).
identity
Indicates the identity function (i.e. no compression, nor modification). This token, except if explicitly specified, is always deemed acceptable.
br
A format using the Brotli algorithm

Examples

Compressing with gzip

Content-Encoding: gzip

Specifications

Specification Title
{{RFC("7231", "Content-Encoding", "3.1.2.2")}} Hypertext Transfer Protocol (HTTP/1.1): Semantics and Content

Browser compatibility

{{Compat}}

See also

  • {{HTTPHeader("Accept-Encoding")}}
  • {{HTTPHeader("Transfer-Encoding")}}

Revision Source

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

<p>The <strong><code>Content-Encoding</code></strong> header indicates which algorithm is used for the message.</p>

<table class="properties">
 <tbody>
  <tr>
   <th scope="row">Header type</th>
   <td>{{Glossary("Response 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">
Content-Encoding: gzip
Content-Encoding: compress
Content-Encoding: deflate
Content-Encoding: identity
Content-Encoding: br
</pre>

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

<dl>
 <dt><code>gzip</code></dt>
 <dd>A format using the <a class="external" href="http://en.wikipedia.org/wiki/LZ77_and_LZ78#LZ77">Lempel-Ziv coding</a> (LZ77), with a 32-bit CRC. This is originally the format of the UNIX <em>gzip</em> program. The HTTP/1.1 standard also recommends that the servers supporting this content-encoding should recognize <code>x-gzip</code> as an alias, for compatibility purposes.</dd>
 <dt><code>compress</code></dt>
 <dd>A format using the <a class="external" href="http://en.wikipedia.org/wiki/LZW">Lempel-Ziv-Welch</a> (LZW) algorithm. The value name was taken from the UNIX <em>compress</em> program, which implemented this algorithm.<br />
 Like the compress program, which has disappeared from most UNIX distributions, this content-encoding is used by almost no browsers today, partly because of a patent issue (which expired in 2003).</dd>
 <dt><code>deflate</code></dt>
 <dd>Using the <a class="external" href="http://en.wikipedia.org/wiki/Zlib">zlib</a> structure (defined in <a class="external" href="http://tools.ietf.org/html/rfc1950">RFC 1950</a>), with the <a class="external" href="http://en.wikipedia.org/wiki/DEFLATE"><em>deflate</em></a> compression algorithm (defined in <a class="external" href="http://tools.ietf.org/html/rfc1952">RFC 1951</a>).</dd>
 <dt><code>identity</code></dt>
 <dd>Indicates the identity function (i.e. no compression, nor modification). This token, except if explicitly specified, is always deemed acceptable.</dd>
 <dt>br</dt>
 <dd>A format using the <a href="https://en.wikipedia.org/wiki/Brotli">Brotli</a> algorithm</dd>
</dl>

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

<h3 id="Preventing_caching">Compressing with gzip</h3>

<pre>
Content-Encoding: gzip</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("7231", "Content-Encoding", "3.1.2.2")}}</td>
   <td>Hypertext Transfer Protocol (HTTP/1.1): Semantics and Content</td>
  </tr>
 </tbody>
</table>

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

<p class="hidden">To contribute to this compatibility data, please write a pull request against this file: <a href="https://github.com/mdn/browser-compat-data/blob/master/http/headers.json">https://github.com/mdn/browser-compat-data/blob/master/http/headers.json</a>.</p>

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

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

<ul>
 <li>{{HTTPHeader("Accept-Encoding")}}</li>
 <li>{{HTTPHeader("Transfer-Encoding")}}</li>
</ul>
Revert to this revision