Skip to main content

Content-Encoding

ResponseActive

The Content-Encoding header indicates what compression has been applied to the response body. The client uses this to decompress the body after receiving it. Content-Encoding differs from Transfer-Encoding – Content-Encoding is a property of the representation itself, while Transfer-Encoding is applied for transport.

Content-Encoding: gzip | br | zstd | deflate | identity

Description

Content-Encoding tells the client how to decode the message body. Common values are gzip (RFC 1952), br (Brotli, RFC 7932), and zstd (Zstandard). The server selects the encoding based on the client's Accept-Encoding header. Multiple encodings can be applied (gzip then br), though this is uncommon.

Directives

DirectiveDescription
gzipGNU zip compression. Widely supported. Typical ratio: 70-80% size reduction.
brBrotli compression. Better ratio than gzip. Requires HTTPS.
zstdZstandard compression. Faster than gzip, similar ratio.
identityNo encoding (the default).

Examples

Gzip response
http
HTTP/1.1 200 OK
Content-Type: application/json
Content-Encoding: gzip
Vary: Accept-Encoding
Brotli response
http
HTTP/1.1 200 OK
Content-Type: text/html
Content-Encoding: br
Vary: Accept-Encoding

Related

Specification

RFC 9110Content-Encoding specification →