What is the Content-Encoding header?
The Content-Encoding header lists any compression that has been applied to the representation body, so the recipient knows which transformation to reverse before decoding. Common values are gzip, br (Brotli), zstd, and deflate.
API Usage & Best Practices
- Pair with
Accept-Encoding: A server should only apply an encoding that the client advertised as acceptable in itsAccept-Encodingrequest header. - Reduce payload size: Compressing JSON responses with
gziporbrcan dramatically cut bandwidth for API responses. - Order matters: When multiple encodings are applied, list them in the order they were applied so the client can reverse them correctly.
Examples
HTTP/1.1 200 OKContent-Type: application/jsonContent-Encoding: gzip