Comparisons & Alternatives

Enable GZIP and Brotli on Your Hosting: Speed Up Your Website Guide

Learn how to enable GZIP and Brotli compression on your Mexican hosting to shrink file sizes and dramatically improve your website's load time.

Three professionals discussing strategies at a whiteboard in an office setting.

Enabling GZIP or Brotli compression on your server shrinks HTML, CSS, and JavaScript files before sending them to the browser, cutting load times by 50–70% without touching a single line of your code.

What Are GZIP and Brotli and How Do They Differ?

Both are compression algorithms the server applies to text-based files before transmitting them. The browser decompresses them automatically on arrival.

Feature GZIP Brotli
Server support Universal (Apache, Nginx, LiteSpeed) Apache 2.4.26+, Nginx 1.11.6+, LiteSpeed
Browser support All modern browsers All modern browsers except IE11
Compression ratio Good (~65–70% on HTML) Better (~15–20% more than GZIP on average)
CPU usage Low Slightly higher (offset by smaller transfer)
Available on shared hosting Almost always Depends on provider and Apache version

Practical recommendation: enable Brotli if your server supports it and use GZIP as a fallback. Most modern hosting plans support both.

How to Check If Compression Is Already Active

Before configuring anything, verify your site's current state. The fastest methods:

  • GTmetrix or PageSpeed Insights: both explicitly flag missing compression.
  • HTTP headers: open browser DevTools (F12), go to the Network tab, reload the page, and inspect the main HTML file. Its response headers should show Content-Encoding: gzip or Content-Encoding: br.
  • curl from the terminal:
curl -H "Accept-Encoding: gzip, br" -I https://yourwebsite.com

If the response includes content-encoding: gzip or content-encoding: br, compression is already on — no action needed.

Enable GZIP on Apache via .htaccess

This is the most common approach for shared hosting. Open or create the .htaccess file in your site's root (via cPanel File Manager or FTP) and add:

<IfModule mod_deflate.c>
  # Enable compression for the most common file types
  AddOutputFilterByType DEFLATE text/html text/plain text/xml
  AddOutputFilterByType DEFLATE text/css text/javascript application/javascript
  AddOutputFilterByType DEFLATE application/json application/xml application/xhtml+xml
  AddOutputFilterByType DEFLATE image/svg+xml font/ttf font/otf application/font-woff

  # Exclude old browsers with broken support
  BrowserMatch ^Mozilla/4 gzip-only-text/html
  BrowserMatch ^Mozilla/4\.0[678] no-gzip
  BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
</IfModule>

Save and upload the file, then verify in DevTools. The change takes effect immediately — no Apache restart required.

Enable Brotli on Apache via .htaccess

If your provider has the mod_brotli module enabled (available since Apache 2.4.26), add this to the same .htaccess file, before the GZIP block so Brotli takes priority when the browser supports it:

<IfModule mod_brotli.c>
  AddOutputFilterByType BROTLI_COMPRESS text/html text/plain text/xml
  AddOutputFilterByType BROTLI_COMPRESS text/css text/javascript application/javascript
  AddOutputFilterByType BROTLI_COMPRESS application/json application/xml application/xhtml+xml
  AddOutputFilterByType BROTLI_COMPRESS image/svg+xml font/ttf font/otf application/font-woff
</IfModule>

Apache automatically serves Brotli to browsers that send Accept-Encoding: br and falls back to GZIP for the rest. No extra logic needed.

What If I Use LiteSpeed (LSCache)?

Hosting plans running LiteSpeed Web Server (common on Hostinger, SiteGround, and many modern providers) compress automatically with both GZIP and Brotli — no extra configuration needed. Just make sure the LiteSpeed Cache plugin is active in WordPress.

Compression in cPanel: Graphical Option

Some providers expose compression settings directly in cPanel:

  1. Open cPanel > Software > Optimize Website.
  2. Select Compress All Content or choose content types manually.
  3. Click Update Settings.

This option writes the mod_deflate directives automatically. If you don't see "Optimize Website," your provider has hidden it — the .htaccess method will work regardless.

Looking for a deeper comparison of hosting performance features? The hosting comparison guides cover real-world speed tests and support quality across providers.

Key Takeaways

  • GZIP and Brotli reduce text-based file sizes by 50–70%, directly improving Core Web Vitals and SEO rankings.
  • Check whether compression is already active (look for the Content-Encoding response header in DevTools) before making any changes.
  • The universal method for shared hosting is adding mod_deflate directives to .htaccess — no root access or Apache restart needed.
  • Enable Brotli if your server supports it and keep GZIP as a fallback; both blocks can coexist in the same .htaccess.
  • LiteSpeed-based hosting compresses automatically — just activate the cache plugin and you're done.

Need a hosting plan that comes with GZIP, Brotli, and caching configured out of the box? The web performance team at elenlace.com can help you find the right plan for your site's needs.

FAQ

Does compression affect images or videos?

No — GZIP and Brotli should never be applied to already-compressed binary formats like JPEG, PNG, WebP, MP4, or ZIP. Doing so can actually increase file sizes. The example directives in this guide already exclude these content types.

Can enabling compression break my website?

It's very unlikely when using the standard directives shown here. In rare cases, aggressive caching plugins can conflict with server-level compression. If you notice corrupted content after enabling it, temporarily disable your caching plugin to isolate the issue.

Does it work with WordPress, Joomla, and PrestaShop?

Yes. Compression operates at the server level and is transparent to any CMS or PHP framework. You don't need to configure anything inside WordPress beyond, optionally, enabling compression through a performance plugin like WP Rocket or LiteSpeed Cache.

How much real improvement can I expect in PageSpeed scores?

On a typical WordPress site without compression, enabling GZIP usually raises PageSpeed scores by 5–15 points and reduces page weight by 40–70%. Results vary depending on your content mix and other performance factors on the site.

Prefer it done for you? El Enlace handles hosting and professional web development.

Further reading

Other providers and guides worth comparing:

← All