Compression Formats (HTTP Layer)
Text responses (HTML, CSS, JS, JSON, SVG) compress well with dictionary codecs. Servers advertise supported algorithms; clients pick via Accept-Encoding; the response carries Content-Encoding.
gzip
Ubiquitous DEFLATE-based compression (Content-Encoding: gzip). Fast encode/decode. Baseline for all HTTP stacks.
Brotli (br)
Typically 15–25% smaller than gzip for web text at similar CPU cost on modern hardware. Static assets benefit from precompressed .br files with a high-quality dictionary window tuned at build time.
Zstandard (zstd)
Facebook’s Zstd offers excellent speed/ratio tradeoffs and a transparent dictionary mode. Emerging in CDNs and reverse proxies; not universally supported by browsers for decompression yet — check Accept-Encoding before enabling on origin responses to browsers.
What not to compress
- Already compressed formats: JPEG, PNG, WebP, AVIF, most video codecs.
- TLS payloads — compression at the TLS layer is disabled in modern stacks (CRIME / BREACH class attacks).