Brotli
Brotli is a compression algorithm developed at Google and standardized
in RFC 7932, negotiated over HTTP as Content-Encoding: br. For text-based
content — HTML, CSS, JavaScript, JSON, SVG — it typically produces
15–25% smaller output than gzip, which translates directly into
faster downloads on every request. All modern browsers support it (and advertise it
via Accept-Encoding: gzip, deflate, br).
Compression levels: static vs. on-the-fly
Brotli has quality levels 0–11. The trade-off:
- Level 10–11 — maximum savings but slow to compress. Ideal for static assets compressed once at build time and served pre-compressed.
- Level 4–5 — what servers and CDNs typically use when compressing dynamically per response. Still beats gzip's default output while staying cheap enough for on-the-fly use.
Newer CDN stacks also offer Zstandard (zstd), which
compresses faster at similar ratios — Brotli remains the most widely supported
upgrade over gzip.
How Brotli interacts with caching
Compressed responses and caching meet at the
Vary header: a response served with
Vary: Accept-Encoding gets a separate cache entry per encoding, so the
cache can hand Brotli to browsers that accept it and gzip to clients that don't.
Most CDNs handle this transparently — Cloudflare, for example, stores one
representation and compresses at the edge on the way out. What matters for you:
whether the edge actually delivers Brotli to end users, regardless of what
your origin sends.
Check what your site really delivers
Plenty of sites serve gzip (or nothing) despite Brotli being one config line away.
The compression test shows which encoding your site
delivers, what Brotli would save per URL, and whether your CDN re-compresses for
you — from a real browser's Accept-Encoding, measured at the edge.