How Content-Encoding works
The server picks one of the encodings the client offered in Accept-Encoding, compresses the body and labels it here; the browser decompresses transparently. Brotli is typically 15–20% smaller than gzip for text. Only compress text-like content: images, video and archives are already compressed.
Examples
Content-Encoding: br
Content-Type: text/javascript
Vary: Accept-Encoding
Common mistakes
-
Don’t send a .tar.gz download with
Content-Encoding: gzip: the browser will decompress it and save a plain tar. UseContent-Type: application/gzipwith no Content-Encoding.
Check it
curl -sI https://example.com | grep -i '^content-encoding:'
Paste a full set of response headers into the HTTP header checker to get every header explained and common mistakes flagged.
Related headers
- Accept-Encoding: lists the compression formats the client can decode.
- Vary: lists the request headers that change the response, so caches keep a separate copy for each value.
- Content-Length: gives the size of the body in bytes.
More content and negotiation headers
Content-Type , Content-Disposition , Accept , Accept-Language , Range , Transfer-Encoding .
Sources
Spotted a mistake? Email hello@devtoolsmith.com and we’ll fix it.
Frequently asked questions
What does the Content-Encoding header do?
The Content-Encoding response header names the compression applied to the body, such as gzip, br (Brotli) or zstd. The server picks one of the encodings the client offered in Accept-Encoding, compresses the body and labels it here; the browser decompresses transparently. Brotli is typically 15–20% smaller than gzip for text. Only compress text-like content: images, video and archives are already compressed.
How do I see the Content-Encoding header?
Run "curl -sI https://example.com" to print a response’s headers, or open the Network tab in your browser’s dev tools and select the request. Paste the headers into the HTTP header checker on this site to get each one explained.