Gzip Compression can be enabled with or without using a WordPress plugin. You can easily enable Gzip Compression by adding the given below code in your .htaccess file. The .htaccess file can be found on your server (Apache) in the root directory of your domain.
Enabling Gzip Compression in WordPress via .htaccess reduces Server Response Time and volume of data sent by the server to a web browser. Moreover, compressed page size help reducing the transferred response and data.
The best way to enable compression is, using mod_gzip or mod_deflate in WordPress .htaccess file. And the good news is, Gzip compression can be enabled by adding a simple code in WordPress .htaccess file (without plugin method) of your website.
Don’t worry if you don’t want to enable compression via .htaccess file. I have also explained how to enable Gzip compression in WordPress using plugins like W3 Total Cache, WP Super Cache, and WP Fastest Cache, etc. In addition to that, I will show you how to enable DEFLATE compression.
Don’t be confused with the title – the Gzip and DEFLATE compression methods using .htaccess file and configuration file are server-dependent (i.e. Apache and Nginx). That means these methods work well with non-WordPress sites like HTML and other CMS based websites etc.
What is Gzip Compression?
When enabled on a website, Gzip compresses the files before transferring them from the server. Hence, it improves pagespeed, loading time and also saves data usage of the user. If you’re interested to know more about Gzip Compression check out these links [1, 2].
How does it work?
The concept of Gzip compression is quite easy.
It uses an algorithm which organizes repeated strings in a single place only, instead of saving those same strings again and again. And it manages those strings with their location values while compression and retrieving data back from compressed files.
Gzip compression works very well with stylesheets and webpages because all these resource files have many repeated strings.
Because of its efficient compression technique, Gzip may reduce the file size by 70-90%.
Let’s have a look at the given below example to understand the Gzip Compression…
Suppose if your HTML file contents following strings…
<h3>Enable Gzip Compression in WordPress </h3>
Then, the compressed file will look like this.
But if your HTML file contents repetitive strings as following…
<h3>Enable Gzip Compression in WordPress</h3>
<h3>Enable Gzip Compression in WordPress via .htaccess</h3>
Then, Gzip compresses the repeated strings once and uses the latter part of your HTML file.
If you are working on pagespeed of your WordPress site then you should apply these too:
- Remove Query Strings from Static Resources to Increase your Website Speed
DEFLATE Compression vs Gzip Compression: The Difference
You might have read on the web about Gzip Compression and DEFLATE compression.
If you haven’t, let me tell you about them in nutshell. Both compression algorithms (Gzip and DEFLATE) are different and used for different servers.
Gzip compression is used on Apache and Nginx servers, while DEFLATE is only used on Apache servers.
Before you start, you must know Gzip compression status of your website. Let’s see, how to do that.
How to Check Gzip Compression
First, you should check whether Gzip Compression is enabled or not on your WordPress site. You can use this Gzip Test Tool for accurate results or you can Google Gzip compression test tool.
If compression is already applied to your site. Then you may check if compression is enabled properly. Or is there still scope for better compression? (the technique which reduces the files-size most is better one).
You also need to find out which web server software (Apache or Nginx) your web host is using. Because Gzip Compression method is different for both servers.
You also need to figure out, how to edit .htaccess/Config file. Here is a detailed guide How to edit WordPress .htaccess file easily you may refer.
Enabling Gzip & DEFLATE Compression in WordPress
You can enable Gzip compression in WordPress with or without using plugin.
- Enable Gzip Compression WordPress via .htaccess – without plugin method
- Enabling Gzip Compression in WordPress using plugin
Enable Gzip Compression in WordPress via .htaccess
As I have mentioned above, enabling Gzip Compression via htaccess/configuration file depends on the server i.e. Apache and Nginx, etc. So we’ll take both cases one by one. However, the process of editing the .htaccess (or configuration file in case of Nginx server) remains the same.
Step by step instructions to enable Gzip Compression in WordPress via .htaccess:
- Log in to Dashboard/cPanel of your website.
- Open .htaccess file (or config file in Nginx).
- Paste the corresponding code (given below) based on server type i.e. Apache or Nginx.
- Save changes and you’re done.
- Now check your site on compression testing tools again. It will definitely reduce your website page size significantly and will increase page-load speed.
Compression on Apache server
Apache server supports Gzip compression as well as DEFLATE compression.
Enable Gzip Compression on Apache server
If you’re your website is hosted on Apache server, add following code in .htaccess file of your website.
Enable DEFLATE Compression in WordPress
If you’re your website is hosted on Apache server, copy and paste the following code in WordPress .htaccess file of your website.
Compression on Nginx server
Nginx server supports only Gzip compression. Let’s see to do that.
Enable Gzip Compression on Nginx server
If your website is hosted on Nginx server, paste the following code in the configuration file of your website.
Results after Applying Compression
My blog TechNumero was hosted on Apache server, so I was using Gzip compression and DEFLATE compression both on my website. And it is reducing webpage size by 82.2%. Initially, my web page size is 42,656 Bytes (without compression) and after compression, my web page size is 7,596 Bytes only. Hence, I managed to save 35,060 Bytes using Gzip Compression on Technumero.com.
Enable Gzip Compression in WordPress using plugin
There are several plugins to the job at hand. Let’s discuss the most reliable and efficient ones.
Gzip Compression with WordPress Plugin – W3 Total Cache
W3 Total Cache is one of the most used caching plugins on WordPress platform. And if you are using this plugin, you can enable Gzip compression via this plugin.
Step by step instructions to enable Gzip compression using W3 Total Cache WordPress plugin:
- Go to WordPress Dashboard > W3 Total Cache Plugin Settings page.
- Navigate to Browser Cache page.
- And Check the Enable HTTP Compression
- Don’t forget to click on Save changes button and you are done.
Enable Gzip Compression with WordPress WP Super Cache Plugin
WP Super Cache is another popular caching plugin. And you can enable Gzip compression with just one click using this plugin.
Follow steps the given below to Enable Gzip compression with WP Super Cache plugin:
- Navigate to WP Dashboard > WP Super Cache Plugin Settings
- Click on the Advanced Tab and
- Then Enable the First option in Miscellaneous settings.
- Save the changes and you’re done.
Use WP Fastest Cache Plugin to Enable Gzip Compression in WP
WP Fastest Cache Plugin is another plugin which you can to enable Gzip compression in WordPress easily.
Followings are the easy steps to Enable Gzip compression using WP Fastest Cache plugin:
- Go to WordPress Dashboard > WP Fastest Cache > Settings.
- Under Settings Tab check the against Gzip to enable it.
- Click Submit to save changes and you’re done.
Wrapping it Up
Gzip Compression is one of the most used technique for file compression. In addition to that, it is also one of the most recommended methods by pro bloggers for PageSpeed Optimization.
Nowadays, Gzip Compressions comes enabled by default with few modern web hosting servers. However, if it is not enabled on your server, now you know, how to enable Gzip Compression.
Feel free to fire your queries via the comment section below. Do let us know, how much file size you have reduced by enabling Gzip Compression?
What is Gzip Compression?
Gzip is a file compression software and a file format. Gzip compressor (software) is used for compression and decompression of the files in Gzip file format. Gzip compresses the files before transferring them from the server to improve to pagespeed, loading time of the website.
How do I enable Gzip Compression?
You can easily enable or disable Gzip Compression on your website by editing/adding a code snippet (given in the above technumero's article) to .htaccess or config file depending on your server type i.e. Apache, Nginx etc. All steps are explained to enable Gzip Compression on a website.
Is Gzip enabled on my website?
To check Gzip compression status of your website you need to test your site using a free Gzip test tool available online. Check out the Gzip test tool recommended by us (technumero.com) in above article for accuracy.
How do I enable Gzip Compression in WordPress?
You can enable Gzip Compression in WordPress with or without using a plugin. We use one of these two methods on our site and recommend it for better results. In above technumero's article, everything is explained step by step to enable Text Compression in WordPress.
In addition to that you may be interested to read the following tutorials: