Help and documentation
Speed High impact Easy 10–20 min
Response compression (Gzip/Brotli)
Without compression, an unnecessarily large amount of data is transferred.
What it is
Compression (Gzip or the more modern Brotli) shrinks text files (HTML, CSS, JS, SVG, JSON) before sending them over the network, easily by 60–80%. The browser decompresses them itself.
Why it matters
Without compression, many times more data is transferred, which slows loading especially on mobile and slow connections. Enabling it is one of the most worthwhile optimizations: minimal work, big effect.
How to do it
- 1Enable Brotli (ideally) or Gzip on the web server / CDN.
- 2Compress text types: HTML, CSS, JS, SVG, JSON, XML.
- 3Don't Gzip images and videos (they're already compressed). Handle them via format.
- 4Verify the response header "Content-Encoding: br/gzip".
Gzip in .htaccess (Apache, mod_deflate)
Correct
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/html text/css application/javascript application/json image/svg+xml
</IfModule>Conclusion
Compression is a classic "quick win": a few lines of config or a toggle at your host saves tens of percent of transferred data. If it's running, verify that it covers all text types; Brotli is the ideal. This should always be enabled.
Related topics