Plainnotes

gzip, brotli, zstd: more compression is not free

2026-06-24 · 2 min readNetwork

nginx defaults to gzip_comp_level 1; many people set 9 because smaller sounds better. On a 40 KB HTML page, level 1 gives 9.8 KB and level 9 gives 9.1 KB — seven percent for three times the CPU.

For static files, precompress at build time and serve with gzip_static on; runtime cost is zero. Brotli is typically 15–20% smaller than gzip on text but slow to compress, so pregenerate rather than enabling dynamic brotli.

Also skip already-compressed types. Re-compressing JPEG, PNG, MP4 or zip files achieves nothing and burns CPU; keep gzip_types to text formats.