Enabling gzip in Nginx can dramatically reduce transfer sizes for HTML, CSS, and JavaScript responses. Our generator outputs a complete gzip block with safe defaults and the proper Vary: Accept-Encoding header.
Compress text formats only; images and archives are already compressed. Add Vary so caches store both variants.
gzip on;
gzip_vary on;
gzip_comp_level 5;
gzip_min_length 512;
gzip_types text/css application/javascript application/json image/svg+xml;Higher levels cost noticeably more CPU for small size gains. text/html is always compressed once gzip is on and does not need listing.
Open the Caching & compression generator
Brotli compresses text smaller but needs a module in Nginx. gzip is universal; serving both is fine if the module is available.