Enable GZIP Compression WordPress - Smaller Text Files, Faster Pages (2026)
Compression shrinks your HTML, CSS and JavaScript before they're sent, often to a fraction of their original size. Most WordPress hosts already enable it, but it's worth checking.
What Compression Does
Text files compress very well because they're full of repeated patterns. Your server compresses files before sending them, and the browser decompresses them on arrival. The result is fewer bytes over the network and faster downloads, especially on mobile.
GZIP is the long-standing standard. Brotli is a newer format that usually compresses text a bit smaller, and modern browsers support it. Both work automatically once enabled on the server.
Which Files Should Be Compressed
| File Type | Compress? | Why |
|---|---|---|
| HTML | Yes | Text, compresses well |
| CSS and JavaScript | Yes | Text, compresses well |
| SVG images | Yes | Text-based |
| JSON and XML (feeds, sitemaps) | Yes | Text-based |
| Fonts (WOFF2) | No | Already compressed |
| JPEG, PNG, WebP, AVIF | No | Already compressed; little gain |
| Video and audio | No | Already compressed |
How to Check If Compression Is On
Open DevTools
Visit your page and open the Network panel.
Click the document or a CSS file
Look at the response headers.
Find Content-Encoding
A value of gzip or br (Brotli) means compression is working.
Check PageSpeed Insights
Missing compression shows up in the Document request latency insight in current Lighthouse versions.
How to Enable Compression
| Method | When to Use |
|---|---|
| Your host's settings | Most managed and shared hosts enable it by default or offer a toggle |
| WP Rocket | Adds GZIP rules automatically on Apache servers via .htaccess |
| Server configuration | On NGINX or custom servers, configure GZIP or Brotli in the server config |
| CDN | Cloudflare and many CDNs compress text files automatically, often with Brotli |
If you use WP Rocket on Apache, GZIP compression is one of its automatic optimizations, with no setting to enable. On NGINX servers, .htaccess rules don't apply, so ask your host to confirm compression is on.
How Much Compression Saves
| File | Uncompressed | With Compression |
|---|---|---|
| HTML page | Larger | Often a fraction of the original size |
| Theme stylesheet | Larger | Usually much smaller |
| JavaScript library | Larger | Usually much smaller |
| Minified file | Already smaller | Compresses a bit further |
Exact ratios vary, but text files commonly shrink substantially. That's why missing compression is one of the most important basics to fix if it's off.
Compression on Different Hosts
| Hosting Setup | Who Handles Compression |
|---|---|
| Shared hosting with Apache | The host, or your caching plugin via .htaccess |
| LiteSpeed hosting | The server, usually on by default |
| Managed WordPress hosting | The host, almost always on |
| NGINX VPS | Your server configuration or control panel |
| Any host behind Cloudflare | Cloudflare compresses text sent to visitors |
If you're behind a CDN, the CDN often handles compression for visitors regardless of your server's settings. Compression on your server still matters for the connection between the CDN and your server.
Troubleshooting Compression
Headers show no Content-Encoding
Compression is off, or a proxy is removing it. Check with your host.
Compressed only some files
Server rules may only cover certain file types. Make sure CSS, JavaScript, SVG and JSON are included.
Double compression errors
Rare, but caused by compressing in PHP and at the server. Use server-level compression only.
Garbled pages after changes
Clear all caches; an old cached file with the wrong headers may be served.
GZIP vs Brotli
Brotli generally produces smaller text files than GZIP at typical settings, which means slightly faster downloads. Many CDNs and modern hosts serve Brotli to browsers that support it and fall back to GZIP for others.
If your CDN offers Brotli, it's worth enabling there. You don't need to choose between them on your server; the browser and server negotiate the best supported option.
A Worked Example
A small site on a basic VPS scores poorly on Document request latency in PageSpeed Insights. Checking the response headers shows no Content-Encoding on the HTML or CSS files, because the server was set up without compression.
The site runs NGINX, so .htaccess rules wouldn't apply. The owner enables GZIP in the server control panel and also turns on the site's Cloudflare proxy, which serves Brotli to supporting browsers. HTML and CSS transfer sizes drop sharply, and FCP improves on mobile connections.
Quick Compression Checklist
- Confirm Content-Encoding shows gzip or br for HTML, CSS and JavaScript.
- Make sure SVG, JSON and XML are included.
- Don't compress images, fonts or video again.
- Enable compression in one place: server, plugin or CDN.
- Re-check after moving hosts or changing CDNs.
Compression and Minification
Compression and minification complement each other. Minification removes unnecessary characters like whitespace and comments; compression then shrinks what's left. Minified files compress a little smaller, but compression does most of the work. See minifying CSS and JavaScript.
Enable GZIP Compression WordPress FAQ
Is GZIP compression enabled on WordPress by default?
Not by WordPress itself, but most hosts and CDNs enable it at the server level.
Does WP Rocket enable GZIP?
Yes, automatically on Apache servers through .htaccess rules.
Should I compress images with GZIP?
No. Images are already compressed. Compression is for text files like HTML, CSS and JavaScript.
Is Brotli better than GZIP?
It usually compresses text a little smaller. Use it if your host or CDN supports it.