Content-Encoding
ResponseActiveThe 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
| Directive | Description |
|---|---|
| gzip | GNU zip compression. Widely supported. Typical ratio: 70-80% size reduction. |
| br | Brotli compression. Better ratio than gzip. Requires HTTPS. |
| zstd | Zstandard compression. Faster than gzip, similar ratio. |
| identity | No encoding (the default). |
Examples
Gzip response
http
HTTP/1.1 200 OK
Content-Type: application/json
Content-Encoding: gzip
Vary: Accept-EncodingBrotli response
http
HTTP/1.1 200 OK
Content-Type: text/html
Content-Encoding: br
Vary: Accept-Encoding