How to Enable GZIP Compression (Apache, Nginx, cPanel) + How to Test It (2026)

Mika Sandgrove | | 3 min read

How to Enable GZIP Compression (Apache, Nginx, cPanel) + How to Test It (2026)

In 2026, performance work is still one of the highest-leverage technical wins you can ship quickly. If you want to enable GZIP compression, you’re reducing the size of text-based responses (HTML, CSS, JS, JSON, SVG) so they transfer faster over the network—often with minimal risk when configured correctly.

Why Enable GZIP Compression?

  • Faster page load times: Smaller payloads mean quicker downloads, especially on mobile and slower connections.
  • Lower bandwidth usage: Compression reduces outbound transfer, which can help control hosting/CDN costs.
  • Indirect SEO support via performance: Faster delivery can improve user experience and Core Web Vitals, which can indirectly support SEO; this aligns with how site speed impacts SEO when you’re prioritising technical fixes.

How to Enable GZIP Compression:

1) Apache: enable GZIP via .htaccess (mod_deflate)

On Apache, the most common approach is mod_deflate. Some hosts block or ignore .htaccess changes—if your rules don’t apply, you may need access to the main vhost config or to ask your host.

Add this to your site’s .htaccess (or, preferably, the relevant VirtualHost config):

<IfModule mod_deflate.c>
  # Compress common text-based content
  AddOutputFilterByType DEFLATE text/html text/plain text/css
  AddOutputFilterByType DEFLATE text/javascript application/javascript application/json
  AddOutputFilterByType DEFLATE text/xml application/xml application/xhtml+xml
  AddOutputFilterByType DEFLATE image/svg+xml

  # Ensure proxies/CDNs cache the right variant
  <IfModule mod_headers.c>
    Header append Vary Accept-Encoding
  </IfModule>

  # Avoid compressing already-compressed/binary assets
  SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png|webp|avif|ico|mp4|mov|mp3|ogg|gz|zip|bz2|br|woff2?)$ no-gzip dont-vary
</IfModule>

Notes:

  • Don’t bother gzipping images/video/fonts—most are already compressed and you can waste CPU for little gain.
  • If you’re on HTTP/2 or HTTP/3, gzip is still widely supported for text assets; Brotli is a great complement (more on that below).

2) Nginx: enable gzip in nginx.conf (or a site include)

In Nginx, gzip is configured in the http {} block (or an included file applied there):

gzip on;
gzip_vary on;
gzip_proxied any;
gzip_http_version 1.1;
gzip_min_length 1024;
gzip_comp_level 5;

gzip_types
  text/plain
  text/css
  text/xml
  text/javascript
  application/javascript
  application/json
  application/xml
  application/rss+xml
  application/atom+xml
  image/svg+xml;

Practical guidance:

  • gzip_comp_level 4–6 is a common balance; higher levels can increase CPU for diminishing returns.
  • If you use Brotli (br) (often via Nginx module or at the CDN), keep gzip enabled as a baseline for broad compatibility—many stacks serve br when supported and fall back to gzip.

3) cPanel (and similar control panels)

Many shared hosts expose compression via a UI toggle, but labels vary by provider and version. Look for options like “Optimize Website”, “Compression”, “Performance”, or “Web Server Settings.”

If you don’t see it:

  • Check whether your host uses Plesk or a custom dashboard.
  • On managed WordPress platforms, compression may be handled at the platform layer.
  • If you’re using a CDN (e.g., Cloudflare or another edge), gzip/Brotli is often enabled at the edge and may not require origin changes.

4) Test your configuration (reliable methods)

Browser DevTools (fastest):

  1. Open DevTools → Network.
  2. Reload the page.
  3. Click the main document or a CSS/JS file.
  4. In Headers, confirm Content-Encoding: gzip (or br).

curl (most explicit):

curl -I -H "Accept-Encoding: gzip" https://example.com/

Look for:

  • Content-Encoding: gzip
  • Vary: Accept-Encoding

If you’re behind a CDN/reverse proxy, headers may reflect edge compression rather than origin compression. That’s fine—what matters is what users receive—but it’s useful to know where the change is being applied when debugging.

Conclusion:

To enable GZIP compression safely in 2026, focus on compressing text-based assets, sending Vary: Accept-Encoding, and avoiding already-compressed binaries. Implement it at the right layer (origin server, control panel, or CDN), then verify with DevTools and curl so you can be confident the correct Content-Encoding is being served.

Mika Sandgrove

Article author

Mika Sandgrove

Mika Sandgrove is an SEO writer and independent SEO consultant with more than three years of experience creating and optimizing content for search. He runs his own SEO practice, helping businesses improve their organic visibility through SEO strategy, content optimization, and technical and on-page SEO services. Much of his work comes through freelance marketplaces and online client platforms, where he works with businesses across different industries and markets. Mika primarily writes about SEO, search visibility, and practical optimization strategies, and is increasingly exploring Answer Engine Optimization (AEO) and how businesses can adapt their content for AI-powered search experiences.