Content-EncodingContent-Encoding states the compression/transformation actually applied to the body. The receiver reads it, restores (decodes) the body to its original form, then interprets it per Content-Type.
It is most often used on responses: the server honors the client's Accept-Encoding preference, compresses with gzip, br, etc., and reports the coding used here. If several codings are applied in sequence, they are listed in the order applied (the receiver decodes in reverse). This is an end-to-end transformation preserved all the way to the final recipient.
Crucially, Content-Length refers to the byte count after encoding, so the Content-Length of a Content-Encoding-compressed response is the compressed size. Content-Type, by contrast, describes the type of the original content once decompressed.
Unlike Transfer-Encoding, which is hop-by-hop and stripped per connection, Content-Encoding is treated as part of the resource representation itself. Thus ETags and caches key on the encoded representation, and `Vary: Accept-Encoding` is required.
Content-Encoding: <coding>[, <coding>]*e.g. Content-Encoding: gzip
gzip | The body is gzip (LZ77) compressed. |
br | Brotli compression applied (preferred on the web). |
deflate | zlib/DEFLATE compression applied. |
zstd | Zstandard compression applied. |