Fix Guide

How to Enable Gzip or Brotli Compression in WordPress

February 8, 2026

Enabling compression on your WordPress site can reduce the size of HTML, CSS, and JavaScript files by 70-90%, significantly improving page load times.

Method 1: Apache (.htaccess) — Gzip

Add this to your .htaccess file:

<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
    AddOutputFilterByType DEFLATE application/rss+xml
    AddOutputFilterByType DEFLATE application/atom+xml
    AddOutputFilterByType DEFLATE image/svg+xml
    AddOutputFilterByType DEFLATE font/ttf
    AddOutputFilterByType DEFLATE font/otf
    AddOutputFilterByType DEFLATE font/woff
</IfModule>

Method 2: Nginx — Gzip

gzip on;
gzip_vary on;
gzip_proxied any;
gzip_comp_level 6;
gzip_types text/plain text/css text/xml application/json application/javascript application/xml+rss application/atom+xml image/svg+xml font/ttf font/otf;

Method 3: Nginx — Brotli

If your Nginx is compiled with the Brotli module:

brotli on;
brotli_comp_level 6;
brotli_types text/plain text/css text/xml application/json application/javascript application/xml+rss image/svg+xml font/ttf font/otf;

Check Your Hosting Provider

Many managed WordPress hosting providers enable compression by default. Before making changes, check with your host. Providers like Cloudflare also offer one-click Brotli compression through their CDN.

Verify with InspectWP

After enabling compression, run a new InspectWP scan. The performance section should show the Content-Encoding as gzip or br (Brotli) instead of empty.

Check your WordPress site now

InspectWP analyzes your WordPress site for security issues, SEO problems, GDPR compliance, and performance — for free.

Analyze your site free