Compression is one of the simplest ways to speed up a website. The server shrinks HTML, CSS and JavaScript files before sending them, and the browser unpacks them on arrival. Smaller files mean less data to download, which helps most on mobile connections. The two algorithms you will meet are GZIP and Brotli.
What GZIP is
GZIP has been the standard for web compression for many years. Every browser and server supports it, and it typically makes text files much smaller. It is fast to compress, which makes it safe to turn on almost anywhere.
What Brotli is
Brotli is a newer algorithm developed by Google. It usually produces smaller files than GZIP for the same content, often in the range of around fifteen to twenty-five percent smaller for text such as HTML, CSS and JavaScript. All modern browsers support it, and it is used over HTTPS connections.
How they compare
- File size: Brotli generally wins, especially at higher compression levels.
- Speed to compress: GZIP is quicker. At the highest Brotli levels, compressing on the fly can be slow, so servers often use a moderate level for dynamic pages and a high level for static files compressed ahead of time.
- Support: GZIP works everywhere. Brotli works in all current browsers over HTTPS, and servers fall back to GZIP for the rest.
- Best use: Brotli for static assets and cached pages, GZIP as the fallback.
What to compress, and what not to
Compress text-based files: HTML, CSS, JavaScript, JSON, SVG and XML. Do not compress files that are already compressed, such as JPEG, PNG, WebP, AVIF, MP4 and WOFF2 fonts. It wastes processing time and gains almost nothing.
How to turn compression on
- Cloudflare or another CDN: Brotli is usually available as a setting. Turn it on and the CDN compresses responses for visitors.
- Apache: enable
mod_deflatefor GZIP andmod_brotliif your host provides it. - Nginx: use the
gzipdirectives and the Brotli module where available. - Managed hosting: many hosts already enable one or both. Check before changing anything.
How to test that it works
Send a request that asks for compression and look at the response headers:
curl -sI -H "Accept-Encoding: br, gzip" https://yourdomain.com/
A content-encoding: br header means Brotli is in use, and gzip means GZIP. You can also open the Network panel in Chrome DevTools and check the content-encoding column. PageSpeed Insights will flag “Enable text compression” if neither is working.
Common problems
- Double compression. If your CDN and server both compress, check that the result is not broken or compressed twice.
- Missing fallback. Keep GZIP enabled so older clients still get compressed responses.
- Compressing the wrong files. Limit it to text types.
How much will it help?
Compression alone will not fix a slow site, but for text-heavy pages it can cut transfer size noticeably. Combine it with caching, a CDN and image optimization. Our WordPress speed checklist shows where compression fits in the full order of work.
Want help with server settings?
Compression, caching and CDN setup are part of our WordPress speed optimization service. Contact us and we will check what your site is using today.
