Compression reduces data sent from server to browser, improving web performance. Developers trade compression ratio for speed, choosing dynamic compression for user-specific responses and static compression for assets like CSS or JavaScript. The IANA recognizes many encoding schemes, but gzip, brotli, and zstd dominate usage per HTTP Archive’s 2025 Web Almanac.
Brotli leads in CDN traffic, while gzip remains common in non-CDN scenarios. Brotli became widely available in 2017, and zstd reached broad platform support in 2026. The article explores how browsers handle concatenated compressed files across formats.
It demonstrates serving uncompressed HTML via a basic Python server, then shows dynamic gzip compression when the Accept-Encoding header is present. The example includes code snippets for a server that conditionally compresses responses using gzip based on client headers. The discussion highlights that while decompression speed matters, compression efficiency—reducing bytes sent—is often prioritized in browser environments.
Static assets allow for more expensive, one-time compression, whereas dynamic responses require faster compression to avoid adding latency. The piece sets up further investigation into whether brotli will overtake gzip in non-CDN traffic by 2026.
Source: Hacker News · Summarized by HeadlinesBriefing