Compression is one of the most-deployed performance optimizations on the web — and one of the least-thought-about. Most stacks default to gzip because nginx and Apache turned it on a decade ago. Brotli and Zstd have appeared in the meantime with materially better tradeoffs, but the upgrade path is unglamorous and the choice is workload-specific.
This is a practical comparison of the three modern general-purpose compressors and how to decide between them.
The Three Contenders
gzip (DEFLATE) is the elder. Built into every browser, every HTTP client, every reverse proxy. Default for Content-Encoding. Reasonable ratio, fast at low levels, slow at high levels.
Brotli (br) is Google's HTTP-focused compressor, released in 2013. Better compression ratios than gzip at every level. Decoding is fast. Encoding at high levels is very slow. Supported by every major browser; not always supported in tooling or backend HTTP clients.
Zstd (zstd) is Facebook's general-purpose compressor, released in 2016. Better ratios than gzip, sometimes better than Brotli depending on the level. Fast encoding and decoding across the entire level range. Increasingly supported in CDN HTTP responses (Content-Encoding: zstd) but not yet universal in browsers.
The headline differences are encode/decode speed and compression ratio at each level. The right choice depends on which axis matters most for your workload.
The Numbers, Approximately
On a typical mixed-content workload (HTML, CSS, JS, JSON), with each compressor at its middle level:
- gzip level 6: 2.5x ratio. Fast encode, fast decode. Default.
- Brotli level 4: 3.0x ratio. Slower encode than gzip, similar decode.
- Zstd level 3: 2.8x ratio. Fast encode (often faster than gzip), fast decode.
At high levels:
- Brotli level 11: 3.5x ratio. Very slow encode (5-20x slower than level 4). Same fast decode.
- Zstd level 22: 3.3x ratio. Slow encode (10x slower than level 3). Same fast decode.
These numbers are approximate and content-dependent. The pattern is robust: Brotli has the best ratio at high levels, Zstd has the best ratio for the CPU cost, and gzip is the universal fallback.
Static vs Dynamic Content
The most important distinction in choosing a compressor is whether the content is compressed once (static assets, cached responses) or every request (dynamic HTML, API responses).
Static content. Compress once at build time or at upload to CDN. Pay any CPU cost; reuse the result forever. Pick the highest-ratio level you can stomach.
- For HTTP-served static (JS bundles, CSS, fonts): Brotli level 11. Best ratio, decode is fast, cost is only at build.
- For storage or cross-system transport: Zstd level 19-22. Comparable ratio, decode is faster across language ecosystems.
Dynamic content. Compress every request. The encode time directly adds to response latency. Use a fast level.
- For HTTP-served dynamic: gzip level 4-6 or Zstd level 3-5. Brotli's middle levels are usually slower than these for the same ratio.
- For backend-to-backend RPC payloads: Zstd level 1-3. Designed for exactly this — fast encode, good enough ratio, both sides typically support it.
The most common mistake: enabling Brotli for dynamic responses at default level 11. The encode cost on every request can add 50-200ms to TTFB.
Brotli Has a Dictionary Advantage
Brotli ships with a 120 KB static dictionary trained on common web content — HTML tags, CSS selectors, frequent English words. For small payloads this is a huge advantage: a 2 KB HTML page may compress 2x better with Brotli than gzip because the dictionary already contains its common patterns.
For large payloads, the dictionary advantage shrinks; the natural patterns in the payload dominate.
This is why Brotli wins so cleanly for static web assets: HTML, CSS, JS, JSON all benefit from the dictionary. It is also why Brotli's advantage is less pronounced for binary content or compressed media (images, video) — the dictionary doesn't apply.
Zstd's Custom Dictionaries
Zstd lets you train your own dictionary on a sample of your data. For workloads with very similar payloads (small JSON objects from the same schema, log lines with the same structure), a custom dictionary can dramatically improve compression — sometimes 5-10x better than no dictionary.
This matters most for:
- Backend RPC payloads with consistent structure.
- High-volume log streams with repeated fields.
- IoT or sensor data with limited variability.
The operational cost is training and distributing the dictionary. For payloads of a few hundred bytes, the savings are large enough to justify the work.
Decode Cost
For end users, decode time matters as much as transfer time. A response that took 200ms to download and 100ms for the browser to decompress is the same as one that took 300ms to download.
- gzip decode is fast and well-optimized in every browser.
- Brotli decode is comparable to gzip — slightly slower on some content, slightly faster on others. Not a deciding factor.
- Zstd decode is faster than both on most content. Browsers that support it run their decoder at near memory-bandwidth speeds.
For the client side, decoding speed is rarely the bottleneck. Network transfer dominates.
Server-Side CPU
For servers, encoding cost is real. A few practical numbers from production deployments:
- nginx gzip at level 6 typically uses 1-3% of total CPU for dynamic content compression.
- Brotli at level 5 uses 2-5%, broadly similar.
- Brotli at level 11 can use 20-40% — this is why "dynamic Brotli at default" is a bad pattern.
- Zstd at level 3 uses 1-2% — often less than gzip for the same content.
These vary by content size and traffic shape, but the pattern holds: keep dynamic compression at fast levels regardless of which algorithm.
Mixed Strategies
Most production deployments use multiple compressors at different points.
- Static assets: Brotli level 11 pre-compressed at build, gzip level 9 pre-compressed as fallback, served via
gzip_staticandbrotli_staticdirectives. - Dynamic responses: Server-side gzip or Brotli at a fast level, depending on what the client accepts (
Accept-Encoding). - Backend RPC: Zstd with a custom dictionary if payloads are small and consistent; raw Zstd otherwise.
- Log storage: Zstd level 19+ for cold archives, level 3 for the hot retention tier.
The mixed approach optimizes each leg of the pipeline for its actual constraints.
CDN and Library Support
A practical note: support is uneven outside the major browsers.
- Brotli is universal in browsers but inconsistent in backend HTTP clients. Many CLI tools, older mobile SDKs, and some language standard libraries don't decode it.
- Zstd in HTTP is rolling out — Chrome, Firefox, and Safari all support it but the percentage of clients seeing it is still below Brotli's.
- gzip is everywhere. Including it as a fallback is non-negotiable.
When your Content-Encoding advertises Brotli or Zstd, clients that don't support it will refuse to decode. The CDN or origin must negotiate based on Accept-Encoding and serve the best supported encoding.
Adoption Sequence
A practical path for an existing gzip-only deployment:
- Add Brotli for static assets. Pre-compress at build, serve with
brotli_static(nginx) or equivalent. No dynamic CPU cost. - Add Brotli for dynamic responses at a low level (4-6). Gzip fallback for non-Brotli clients. Measure TTFB before and after.
- Evaluate Zstd for backend-to-backend traffic. If RPC payloads are large or repetitive, the savings are immediate.
- Consider Zstd at the edge once browser support is sufficient for your audience. As of 2026, this is typically 80%+ of traffic.
Each step is incremental and measurable. None of them requires re-architecting; all of them require enabling the right flags on the right software.
A Closing Heuristic
Compression is one of the highest-leverage performance optimizations in any stack. The decade-old gzip-everywhere default works, but Brotli for static and Zstd for backend traffic both pay for themselves quickly. The mistake is using one algorithm for everything because it is the default; the right answer is matching the algorithm to the constraint.
Deciding which compression to use where in your stack? We help teams choose compression strategies that match each leg's CPU budget and bandwidth profile. scopeforged.com