--- title: Content-Encoding slug: Web/HTTP/Headers/Content-Encoding tags: - Cabeçalhos - HTTP - Reference - Referencia translation_of: Web/HTTP/Headers/Content-Encoding ---
The Content-Encoding
entity header is used to compress the media-type. When present, its value indicates which encodings were 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.
The recommendation is to compress data as much as possible and therefore to use this field, but some types of resources, such as jpeg images, are already compressed. Sometimes, using additional compression doesn't reduce payload size and can even make the payload longer.
Tipo de cabeçalho | {{Glossary("Entity header")}} |
---|---|
{{Glossary("Forbidden header name")}} | não |
Content-Encoding: gzip Content-Encoding: compress Content-Encoding: deflate Content-Encoding: identity Content-Encoding: br // Múltiplo, em ordem nos quais serão aplicados Content-Encoding: gzip, identity Content-Encoding: deflate, gzip
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 sent along in an HTTP request. The {{HTTPHeader("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.
Especificação | Título |
---|---|
{{RFC("7932", "Brotli Compressed Data Format")}} | Brotli Compressed Data Format |
{{RFC("7231", "Content-Encoding", "3.1.2.2")}} | Hypertext Transfer Protocol (HTTP/1.1): Semantics and Content |
{{RFC("2616", "Content-Encoding", "14.11")}} | Content-Encoding |
{{Compat("http.headers.Content-Encoding")}}