Gzip vs Brotli vs Zstandard: Web Compression Trade-Offs
When optimizing web performance, web development engineers evaluate data compression algorithms to balance file size reduction against CPU overhead and latency. This evaluation centers on Gzip, Brotli, and Zstandard (zstd), with engineers assessing compression ratios, encoding and decoding speeds, dynamic versus static asset delivery, and client-side browser support. Selecting the optimal algorithm involves determining whether the priority is conserving server compute, maximizing bandwidth savings, or minimizing time-to-first-byte (TTFB) for end users.
Compression Ratio vs. Speed
The fundamental trade-off in web compression is the ratio of data reduction compared to the time and CPU resources required to compress and decompress data.
- Gzip (DEFLATE): Gzip is the long-standing industry baseline. It offers moderate compression ratios with low CPU utilization and fast compression times across its standard levels (1–9). While efficient, modern alternatives consistently outperform it in file size reduction.
- Brotli: Developed primarily for the web, Brotli incorporates a built-in static dictionary containing common web strings (such as HTML tags and standard JavaScript keywords). At high compression levels (10–11), Brotli achieves significantly smaller file sizes than Gzip—often 15% to 25% smaller for text assets. However, maximum compression levels are CPU-intensive and slow.
- Zstandard (zstd): Designed for real-time scenarios, Zstandard provides compression ratios comparable to Brotli at lower levels, but with dramatically faster encoding and decoding speeds. Zstandard scales smoothly across levels 1 through 22, allowing granular trade-offs between speed and size.
Decompression Overhead on the Client
Decompression happens on the user's device, where CPU power may be limited (e.g., lower-end mobile devices).
- Zstandard leads in decompression efficiency, often decompressing data multiple times faster than Gzip and Brotli regardless of the compression level used.
- Gzip maintains fast, predictable decompression speeds with very low memory overhead.
- Brotli requires more client memory and time to decompress than Gzip or Zstandard, particularly when compressed at maximum levels, though the reduced download time usually offsets this overhead on typical network connections.
Static vs. Dynamic Asset Handling
Engineers categorize content into static and dynamic streams to apply different compression strategies:
- Static Assets (HTML, CSS, JS bundles, fonts): Because static files are built once and served many times via CDNs, compression speed during build time is negligible. Engineers default to Brotli at level 11 to achieve the smallest possible payload over the wire.
- Dynamic Assets (API responses, server-rendered
HTML): Compressing content on-the-fly directly impacts server
latency and TTFB. High compression levels create CPU bottlenecks. For
dynamic traffic, engineers evaluate:
- Brotli (levels 4–5): Provides a superior ratio to Gzip with acceptable CPU cost.
- Zstandard (levels 1–3): Provides near-instantaneous compression with ratios beating standard Gzip, making it ideal for high-throughput APIs.
- Gzip (level 6): Remains a dependable default when server CPU capacity is strictly constrained.
Ecosystem and Browser Support
An algorithm's theoretical advantage is limited by protocol and client support:
- Gzip (
Accept-Encoding: gzip): Supported by virtually 100% of HTTP clients, proxies, and web servers. It remains the universal fallback. - Brotli (
Accept-Encoding: br): Supported by all modern browsers over HTTPS. Most modern web servers (Nginx, Caddy, Apache) and edge networks/CDNs (Cloudflare, Fastly, AWS CloudFront) natively support Brotli negotiation. - Zstandard (
Accept-Encoding: zstd): Standardized under RFC 8878, Zstandard has gained support in Chromium-based browsers and Firefox. While CDN and edge support is growing rapidly, older infrastructure often lacks native zstd parsing, requiring fallback chains.
Evaluation Workflow
In production, engineers configure web servers and CDNs to evaluate
the incoming Accept-Encoding header dynamically. The
industry-standard negotiation preference typically resolves as:
- Zstandard (
zstd) for high-throughput dynamic responses where fast edge compression and client decompression minimize latency. - Brotli (
br) for static pre-compressed assets to minimize transfer size, and for dynamic content if zstd is unavailable. - Gzip (
gzip) as the universal fallback for legacy clients, HTTP proxies, or internal microservice communication where broad compatibility is mandatory.