Gzip and Brotli compression for faster pages

Compression shrinks HTML, CSS and JavaScript before sending them, often by 70 % or more. It is one of the easiest speed wins.

Gzip and Brotli

  • Gzip is supported everywhere.
  • Brotli usually compresses text further and is supported by modern browsers over HTTPS.

How to turn it on

Most hosts let you enable it in the control panel. On Apache, mod_deflate (gzip) and mod_brotli; on Nginx, the gzip and brotli modules.

How much it saves

Typical HTML, CSS and JavaScript files shrink by 60–80 % with gzip, and often a little more with Brotli. On a page with 500 KB of text files, that can save several hundred kilobytes per visit.

What not to compress

Images, videos, PDFs and font formats like WOFF2 are already compressed. Compressing them again wastes server time for little or no gain.

Pre-compression

Static files can be compressed once at build time and stored, so the server sends them instantly without compressing on every request. Many CDNs do this for you.

Check after changes

Server moves, new CDNs and configuration changes can switch compression off without anyone noticing. Add a compression check to your post-change checklist.

Check it

The server compression checker and Brotli checker show whether a page is compressed and how much it saves. Images are already compressed, so compression mainly helps text files.

0 comments

Leave a comment

Not shown publicly.