Last updated - July 8, 2021
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?
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.
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.
How to enable GZIP Compression?
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.
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.
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.
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.
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.
- 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.
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/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/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 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_disable "MSIE [1-6]\.(?!.*SV1)";
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.
If you prefer a video version, please check out the video below: