How to Enable GZIP Compression on WordPress Site?

Enable GZIP Compression

Last updated - February 24, 2020

As we have discussed several times before, page load speed is an important aspect that determines the success of your WordPress site. It plays a major role in user experience as well as search engine ranking. So, as a WordPress site owner, you will have to try several strategies to ensure fast page load speeds. One of the popular strategies recommended by experts will be to enable GZIP compression on your WordPress site. In this article, we will discuss more on GZIP compression and how you can enable it for a superior performance of your WordPress site.

What is GZIP Compression?

GZIP is a file format that will reduce the size of HTML, CSS and JavaScript files so that they are served faster when a user requests for it. It is generally done on the server side and helps in a significant reduction of file size. It is one of the essential optimization strategies that you will generally see on a WordPress website.

All browsers that are commonly used now support GZIP compression, and looks for the specific header while making an HTTP request. If the specific header of GZIP compression is present, browsers will serve the compressed files that are of reduced size. This makes sure that all your users will benefit from faster page load speeds thanks to GZIP compression.

The importance of enabling GZIP compression

Good page load speed is an essential requirement for a WordPress website. You will have to try out different optimization strategies to ensure a smooth performance of your website. It is relatively simple to enable GZIP compression and hence most website owners make sure that it is done.

Now, if you have not enabled GZIP compression, you might notice an error on page speed tests by popular tools. For example, if you have enabled GZIP compression on your site you will be able to see a perfect score for ‘Enable Compression’ on your GTMetrix audit.

Enable GZIP Compression
If you have not enabled GZIP compression on your WordPress pages, most page speed test tools will show it as an error.

You can also check whether GZIP compression is enabled on your site by using the developer tools on your browser. For example, on Chrome, you can go to developer tools and check the Response headers. Here you will see ‘Content Encoding: gzip’. This means GZIP compression is enabled.

Enable GZIP compression
Use the developer tools on your browser to ensure GZIP compression is enabled on your browser.

How to enable GZIP Compression?

You have to enable GZIP compression to make sure certain resources like HTML, JavaScript and CSS are served in a compressed form. This will ensure that web pages are loaded pretty fast on your site. If there are large files that are not compressed, they can significantly affect page load speeds on your site.

To enable GZIP compression, you can follow some of the common steps suggested by experts. Here are some of them:

Reach out to the support team of your hosting service

GZIP compression is a commonly used web optimization strategy. Hence, a lot of hosting services enable GZIP compression by default. You can check using the above strategies to ensure that it is enabled. In case, it is not enabled on your site, you can always raise a support request to your hosting service provider. Most popular hosting service providers will oblige with your request.

If you are a WordPress beginner and do not feel comfortable managing the technical aspects of your site, this is the best possible way. A good hosting service provider will have no problems in getting this done for you.

Check out some of the popular hosting services for a WordPress site.

Use plugins to enable GZIP compression

Another relatively simpler option will be to use a caching plugin with GZIP compression support. Such plugins will have options to enable GZIP compression in their settings. If your caching plugin does not have access to modify files on your server, you may still have to ask your hosting service provider.

Here are some of the plugins that will help you enable GZIP compression on your WordPress website.

WP Rocket

WP Rocket is a powerful solution that will help you optimize and speed up your WordPress website. It is a plugin that involves only minimum and simple configuration steps so that even beginners can easily set it up. It will help compress HTML, JavaScript and CSS files so that your web pages will load faster.

Advanced features and great support sets apart WP Rocket from the rest of the caching plugins.
Additional features

The plugin also helps you in the following aspects related to optimization.

  • Instant activation of page caching
  • Preloading of cache to facilitate faster indexing by search engines.
  • Lazy loading of images
  • Flexible for developer-level customization.

Enable GZIP Compression

This is a simple plugin that you can download and use if your website is running on Apache HTTP server. You can use it specifically to enable GZIP compression. However, if you need some more advanced optimization features, consider the premium version.

Premium version features

In addition to helping you enable GZIP compression, the premium version also helps you to:

  • Set document expire times
  • Enable image lazy loading
  • Block image hotlinking

It is also compatible with WooCommerce and hence you can use it if you are running an online store as well.

PageSpeed Ninja

This is another popular WordPress performance plugin that will help you enable GZIP compression easily. Once you install the plugin, you can enable the option easily along with several other options that will help you optimize your site performance.

Enable GZIP compression
You can simply enable the option for compression in the plugin settings.

WP Super Cache

This is another plugin that you can use to compress files on your website. You will be able to enable this option in the plugin settings. It will also help in converting dynamic files to static while serving to users. That means a majority of users such as those who has not logged in will get the static version that is easier to load. This will help to make sure the site is performing optimally.

This is one of the most popular WordPress caching plugins, and has multiple configuration options that you can choose depending on your technical expertise

W3 Total Cache

This plugin will help a lot in improving the search engine ranking as well as user experience of your WordPress website. It offers several advanced features to improve page load speed on your website including compression of HTML, JavaScript and CSS files. Moroever, it also offers CDN integration to help you avoid latency when serving customers globally.

W3 Total Cache is a complete package that helps with overall aspects of your site’s performance
Additional features

Some of the other features you will get with this plugin are:

  • Lazy loading to improve the page load speed as well as user experience.
  • Browser caching using cache-control to deliver pages faster.
  • JavaScript grouping by the template with embed location control.
  • Non-blocking JavaScript embedding.
  • WP-CLI support for cache purging

Editing your .htaccess file (Apache)

If GZIP compression is not enabled on your WordPress site, you can manage that by editing the .htaccess file. You can find the .htaccess file on your root WordPress install using an FTP tool. Once you find the .htaccess file of your WordPress install, you can insert the following code below the # End WordPress tag. Be careful when you perform this step, as a wrongly configured .htaccess file could break your website.

It is always advisable to store backups of your site before making any code changes. Here is how you can create a backup of your WordPress site. If you are unsure of making code-level changes on your WordPress site, you can always get expert help from one of the popular WordPress maintenance service providers

# Compress HTML, CSS, JavaScript, Text, XML and fonts
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/vnd.ms-fontobject
AddOutputFilterByType DEFLATE application/x-font
AddOutputFilterByType DEFLATE application/x-font-opentype
AddOutputFilterByType DEFLATE application/x-font-otf
AddOutputFilterByType DEFLATE application/x-font-truetype
AddOutputFilterByType DEFLATE application/x-font-ttf
AddOutputFilterByType DEFLATE application/x-javascript
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE font/opentype
AddOutputFilterByType DEFLATE font/otf
AddOutputFilterByType DEFLATE font/ttf
AddOutputFilterByType DEFLATE image/svg+xml
AddOutputFilterByType DEFLATE image/x-icon
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/javascript
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/xml


# Remove browser bugs (only needed for really old browsers)
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
Header append Vary User-Agent

Most of the servers will be using Apache, and the above process works in those cases. However, if you are using NGINX or IIS, the process is slightly different.

Enabling GZIP Compression for NGINX

For NGINX servers, you will have to find the nginx.conf file, and add the following code.

gzip on;
gzip_disable "MSIE [1-6]\.(?!.*SV1)";
gzip_vary on;
gzip_types text/plain text/css text/javascript image/svg+xml image/x-icon application/javascript application/x-javascript;

This will help to enable GZIP compression on your website if you are using NGINX servers.

Compression for IIS 7 users

If you are using Microsoft IIS servers, the process is slightly different. IIS uses two different types of compression – dynamic and static.

You can follow the instructions in the Microsoft IIS documentation to enable both types of compression.

Hopefully, this article has provided you an overview of how to enable GZIP compression on your WordPress website. This is one of the important optimization strategies and one that is relatively simple. Leave us a comment if you have a query.

Further reading

LEAVE A REPLY