Content-Encoding Header Explained
What the HTTP Content-Encoding header does and when it's used.
Published October 16, 2026
Content-Encoding states the compression applied to the body (gzip, br, deflate) so the client can decompress it.
How it works
It is paired with Accept-Encoding in negotiation.
The Content-Encoding header is part of the HTTP message and is case-insensitive in name.
In a real exchange
curl -i https://example.com/
Content-Encoding: gzip
Practical examples
The header
Content-Encoding: gzipSet or use it in code
gzip_types text/css application/javascript application/json;Inspect it
curl -sI https://example.com | grep -i 'content-encoding'Common mistakes
- Double compression
- Compressing images and videos
- Setting the header without actually compressing
Key takeaways
- Content-Encoding: Content-Encoding states the compression applied to the body (gzip, br, deflate) so the client can decompress it.
- Check it in browser DevTools → Network.
- Test with curl -I before deploying.
FAQ
Content-Encoding vs Transfer-Encoding?
Content-Encoding applies to the resource; Transfer-Encoding to the hop.
Is Content-Encoding case sensitive?
Header names are case-insensitive; values may not be.