The 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 Content-Type
header.
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
gzip
x-gzip
as an alias, for compatibility purposes.compress
deflate
identity
br
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.
Content-Encoding: gzip
Note that the server is not obligated to use any compression method. Compression highly depends on server settings and used server modules.
Specification | Title |
---|---|
RFC 7231, section 3.1.2.2: Content-Encoding | Hypertext Transfer Protocol (HTTP/1.1): Semantics and Content |
http://www.ietf.org/id/draft-alakuijala-brotli | Brotli Compressed Data Format |
Feature | Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | Servo |
---|---|---|---|---|---|---|---|
Content-Encoding | (Yes) | (Yes) | (Yes) | (Yes) | (Yes) | (Yes) | (Yes) |
Feature | Android | Chrome for Android | Edge Mobile | Firefox for Android | IE Mobile | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|---|---|
Content-Encoding | (Yes) | (Yes) | (Yes) | (Yes) | (Yes) | (Yes) | (Yes) |
© 2005–2017 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Encoding