Content-Encoding entity header is used to compress the media-type. When present, its value indicates what additional content encoding has been applied to the entity-body. It lets the client know, how to decode in order to obtain the media-type referenced by the
It is recommended to compress data as much as possible and therefore to use this field, but some type of ressources, like jpeg images, are already compressed and sometimes using an additional compression doesn't bring anything and can even make the payload longer.
|Header type||Entity header|
|Forbidden header name||no|
Content-Encoding: gzip Content-Encoding: compress Content-Encoding: deflate Content-Encoding: identity Content-Encoding: br
- 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-gzipas an alias, for compatibility purposes.
- 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).
- Using the zlib structure (defined in RFC 1950), with the deflate compression algorithm (defined in RFC 1951).
- Indicates the identity function (i.e. no compression, nor modification). This token, except if explicitly specified, is always deemed acceptable.
- A format using the Brotli algorithm.
Compressing with gzip
On the client side, you can advertise a list of compression schemes that will be send along in an HTTP request. The
Accept-Encoding header is used for negotiating content encoding.
Accept-Encoding: gzip, deflate
The server responds with the scheme used, indicated by the
Content-Encoding response header.
Note that the server is not obligated to use any compression method. Compression highly depends on server settings and used server modules.
|RFC 7231, section 184.108.40.206: Content-Encoding||Hypertext Transfer Protocol (HTTP/1.1): Semantics and Content|
|http://www.ietf.org/id/draft-alakuijala-brotli||Brotli Compressed Data Format|
The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
|br||50||No support||44.0||No support||36.0||No support||?|
|Feature||Android||Chrome for Android||Edge Mobile||Firefox for Android||IE Mobile||Opera Mobile||Safari Mobile|
|br||51||51||No support||44.0||No support||No support||No support|