How to Enable GZIP Compression in WordPress to Speed Up Your Website

Page speed is one of the more direct levers you can pull on a WordPress site. Most of the changes that make a real difference are technical rather than visual, which is why they often get overlooked by site owners focused on content and design. GZIP compression is one of the simpler ones — it reduces the size of files your server sends to visitors’ browsers before they arrive, which means pages load faster without any change to how they look.

For most sites, enabling GZIP reduces the size of HTML, CSS, and JavaScript files by 60–80%. That’s a significant reduction in the data transferred on every page load, and it takes effect immediately for all visitors once it’s active.

Quick Answer

GZIP compression is often already enabled at the server level on managed WordPress hosting. Check whether it’s active by running your site through GTmetrix or Google PageSpeed Insights and looking for a “Enable compression” or “Serve compressed assets” recommendation — if it doesn’t appear, GZIP is already working. If compression isn’t active, enable it via your hosting control panel, your caching plugin’s settings, or by adding a few lines to your .htaccess file.

What GZIP Compression Does

When a visitor requests a page, your server sends a set of files — the HTML of the page, the CSS that styles it, the JavaScript that runs on it. Without compression, these are sent at full size. With GZIP enabled, the server compresses those files before sending them, and the visitor’s browser decompresses them on arrival. The process is fast enough that the decompression overhead is negligible, while the transfer size reduction is substantial.

Text-based files compress very well — HTML, CSS, and JavaScript typically achieve 60–80% size reduction. Binary files like images don’t benefit from GZIP because they’re already compressed in their own format (JPEG, PNG, WebP). GZIP works alongside image optimisation, lazy loading, and a CDN — it handles the text assets while those other techniques handle everything else. Google treats page speed as part of the overall page experience signal, and compression is one of the foundational elements of that. Their documentation on page experience covers how these signals factor into search.

Step 1: Check Whether GZIP Is Already Active

Before making any changes, check whether GZIP is already enabled on your site. Most managed WordPress hosts (Kinsta, WP Engine, SiteGround, Hostinger) enable it at the server level by default.

The quickest way to check is to run your URL through GTmetrix (gtmetrix.com) or Google PageSpeed Insights. In GTmetrix, look at the Waterfall tab — requests for HTML, CSS, and JS files should show small transfer sizes relative to their actual file sizes if compression is active. In PageSpeed Insights, a recommendation labelled “Enable text compression” means GZIP (or Brotli, a similar algorithm) is not active. If that recommendation is absent, compression is already working.

You can also check directly using a browser developer tool. Open your site, press F12, go to the Network tab, reload the page, click on the main HTML document request, and look at the Response Headers for content-encoding: gzip or content-encoding: br (Brotli). Either confirms compression is active.

Step 2: Enable GZIP Compression

If compression isn’t active, there are three ways to enable it depending on your hosting setup.

Option 1: Via Your Caching Plugin

Most WordPress caching plugins include a GZIP compression option. In LiteSpeed Cache, go to LiteSpeed Cache → Page Speed and look for the GZIP settings. In W3 Total Cache, find it under Performance → Browser Cache → Enable HTTP (GZIP) compression. In WP Super Cache, it’s under Settings → Advanced → Compress pages.

Enable the option, save, and then clear your cache. Re-run the PageSpeed or GTmetrix check to confirm compression is now active. This is the simplest route for most WordPress sites and doesn’t require touching server configuration files.

Option 2: Via .htaccess (Apache Servers)

If your site runs on an Apache server and your caching plugin doesn’t include a compression option, you can enable GZIP directly in your .htaccess file. Access it via your hosting file manager or FTP — it’s in the root directory of your WordPress installation.

Add the following block before the WordPress rewrite rules (before the # BEGIN WordPress comment):

<IfModule mod_deflate.c>
  AddOutputFilterByType DEFLATE text/html
  AddOutputFilterByType DEFLATE text/css
  AddOutputFilterByType DEFLATE text/javascript
  AddOutputFilterByType DEFLATE text/xml
  AddOutputFilterByType DEFLATE text/plain
  AddOutputFilterByType DEFLATE application/javascript
  AddOutputFilterByType DEFLATE application/x-javascript
  AddOutputFilterByType DEFLATE application/json
  AddOutputFilterByType DEFLATE application/xml
</IfModule>

Save the file and verify the change using the browser developer tools or a speed testing tool.

Option 3: Via Nginx Configuration

On Nginx servers, GZIP is enabled in the server configuration file rather than .htaccess. Most managed WordPress hosts handle this at the server level, so you typically don’t need to edit Nginx config directly. If you’re on a VPS and managing your own server, add the following to your Nginx config within the http block:

gzip on;
gzip_types text/plain text/css text/javascript application/javascript application/json application/xml;
gzip_min_length 1000;
gzip_proxied any;

Reload Nginx after making changes (sudo nginx -s reload) and verify using the developer tools header check described above.

Step 3: Verify Compression Is Working

After enabling GZIP, clear all caches — your WordPress caching plugin, any CDN cache, and your browser cache — then run the PageSpeed Insights check again. The “Enable text compression” recommendation should no longer appear.

Check a few page types beyond the homepage — a blog post, a category archive, any page that loads a significant amount of CSS or JavaScript from plugins. Compression applies globally once enabled, but it’s worth confirming across different page types.

Practical Tips

Don’t compress files that are already compressed. GZIP has no meaningful effect on images, videos, PDFs, or fonts in WOFF2 format — these are already compressed. Some caching plugin configurations attempt to compress everything, which wastes processing time. Stick to text-based assets.

Brotli is a newer compression algorithm that achieves better compression ratios than GZIP on supporting browsers. Most modern managed hosts support Brotli alongside GZIP. If your host or CDN offers it, enable it — browsers that support Brotli will use it automatically, while others fall back to GZIP.

GZIP works well alongside a CDN. When you use a CDN, compressed files are cached and served from edge locations closer to the visitor. The combination of compression and CDN delivery gives significantly faster load times than either alone — for setup, see the guide on how to set up a CDN for WordPress.

Common Mistakes

Enabling compression but not clearing the cache. If your caching plugin serves cached versions of pages, those cached files were generated before compression was active. Clear the cache after enabling GZIP so new compressed versions are generated.

Enabling GZIP twice. If your host already enables GZIP at the server level and you also add .htaccess rules, some servers will attempt to compress already-compressed output. This can cause errors or corrupt responses. Always check whether compression is already active before adding your own rules.

Expecting GZIP to fix slow images. GZIP has no effect on image file sizes. Image optimisation — converting to WebP, compressing at upload, and using lazy loading — is a separate optimisation. The guides on enabling lazy loading in WordPress and improving WordPress speed and performance cover those areas.

Conclusion

Check whether compression is already active before making any changes — on most managed WordPress hosts it is. If it isn’t, enable it through your caching plugin first, then fall back to .htaccess or server config if needed. Clear your cache, verify with a speed tool, and move on. GZIP is a one-time setup that delivers a consistent improvement on every page load from that point forward. For a broader overview of the steps involved in building and optimising a WordPress website, the essential steps to building a WordPress website covers each stage in order.