Compression is the cheapest speed win on the web: the same HTML travels in a third of the bytes. Yet it is routinely misconfigured — enabled on files that don’t benefit, missing on files that do, or cache headers that undo the benefit by re-downloading everything. This article shows how to check compression properly, not just “is gzip on”.
Quick check with curl
Servers compress only when the client asks for it. Ask explicitly:
curl -s -H 'Accept-Encoding: gzip, br' -o /dev/null -w '%{size_download}\n' https://example.com/
curl -s -H 'Accept-Encoding: gzip, br' -I https://example.com/ | grep -i content-encoding
What to look for in the response:
content-encoding: brorgzip— compression is on;br(brotli) is generally 15–20% smaller than gzip for text.- No
content-encodingheader at all — the response travels uncompressed. content-lengthabsent andtransfer-encoding: chunkedpresent — normal for compressed dynamic responses; judge bysize_download, not by the header.
To see the real saving, compare two sizes: the uncompressed body and the compressed one. A quick way without a terminal: open DevTools → Network → reload → click the document row → Size shows both (“X kB transferred / Y kB resources”).
Don’t forget the cache: compression and Cache-Control are a pair
Compression saves the first visit; caching saves all the others. Check the response’s cache-control header next to content-encoding:
max-age=31536000, immutableon static assets — hashed files (with fingerprint in the name) can safely live in the browser for a year.no-storeon HTML — usually intentional for dynamic pages; fine, as long as assets are cached.no-cacheis not “don’t cache” — it means “cache but revalidate” (withETag/If-None-Match), which is still cheap.vary: accept-encodingmust be present on compressed responses served by CDNs/proxies — otherwise a proxy may hand a gzipped copy to a client that can’t decompress it.- No validators (
ETag/last-modified) — every visit is a full re-download even of “cached” files.
When in doubt about what the headers mean in practice, a bulk cache-header checker reports TTL, validators and the effective policy for every host in your list at once.
When compression doesn’t pay off
Compression is not free: the server spends CPU, and tiny files spend more on gzip overhead than they save. Realistic rules:
- Skip files under ~1 KB — the gzip dictionary header costs bytes; saving on a 900-byte response is noise.
- Already-compressed formats don’t compress again: images (JPEG/WebP/AVIF), video, archives, WOFF2 fonts. Trying to gzip them wastes CPU and can even make them slightly larger.
- Compress text aggressively: HTML, CSS, JS, JSON, SVG, XML — these are where the 60–80% savings live.
- Brotli level trade-off: brotli at maximum quality is slow to compress; use it for static pre-compressed files, and a mid-level (4–5) or gzip for on-the-fly responses.
A proper check measures the actual saving, not the header. The bulk compression checker makes two passes per URL — one browser-like (with decompression) and one asking explicitly without decompressing — and reports the measured encoding and the percentage saved, marking big pages (>32 KB) without compression as a problem. For a quick look at a single domain, the instant compression check gives the same verdict without a terminal. And if you’re tuning speed overall, TTFB checks show whether the server is slow before compression even matters.
Common mistakes
- Double compression (“double gzip”) — an intermediary compresses an already-compressed response; browsers then fail to decode it. Usually a misconfigured proxy or an old module both compressing.
- Gzipping on the fly what should be pre-compressed — high brotli levels per-request eat CPU on every visit; pre-compress static assets at deploy time.
- Missing
vary: accept-encodingon CDN-cached compressed content — corrupted responses for some clients. - Testing with a URL the CDN doesn’t compress (e.g. a redirected URL) and concluding compression is off — check the final hop.
Measure, don’t guess: run a bulk compression check across your domain list — encoding and measured savings for every host in one report.