Enable GZIP Compression

All new web browsers have the ability to read HTML, CSS and JavaScript files in compressed form. This means that the contents of your site can be sent across the Internet in much smaller packets than they actually are which in turn significantly reduces the time it takes to get these assets loaded to the end user.

In order for GZIP compression to work, it has to be enabled on the server (ask your webhost), and the necessary rules placed in your .htaccess file, located in the root directory of your site.

How GZIP Compression Works

Once activated, WP Rocket adds GZIP Compression rules in your .htaccess file using the mod_deflate module.

Enabling GZIP on Dedicated Apache Servers

If you run a dedicated Apache server you can activate mod_deflate by executing this command line:

a2enmod deflate

…and restart the server afterwards:

service apache2 restart

When it does not Work

There are two possible causes if GZIP Compression doesn’t take effect.

  • You don’t have mod_deflate enabled on your server. Contact your hosting provider and ask them to activate it.
  • A plugin, or your theme conflicts by adding its own GZIP compression rules. Deactivate all other plugins, switch to a default theme and check if it works then.

GZIP Compression and NGINX

Nginx doesn’t contain .htaccess. To enable GZIP on NGINX you can follow this guide:

Or you can use this alternate configuration for NGINX provided by one of our customers: