What is Gzip Compression?
Gzip is a file format and a software application used for file compression and decompression. Enabling Gzip Compression reduces file size by 60% to 80%, which helps the server for faster network transfers.
Enabling gzip on your server increases the page load speed of your website. Even, I myself use Gzip compression on my websites.
How to enable Gzip compression
You can enable Gzip compression using the following methods:
- Compression is enabled via .htaccess file on your server
- By Using W3 Total cache
Enable compression via .htaccess
To enable compression via .htaccess file put the following code in your .htaccess file on your server.
For Apache web servers with mod_gzip
The code below should be added to your .htaccess file
You can also compress using the DEFLATE mod. To do so, you have to add the following code in .htaccess file. Don’t know how to edit the .htaccess file? Read about 3 correct ways to edit .htaccess file.
For Apache web servers with mod_deflate:
You can use any one code of the above to enable compression on your server. Mod_gzip enables Gzip compression. Mod_deflate compress the output files from your server before it is being served to your visitor. Both have good results with the compression so you can use any one of them.
Enable compression on NGINX web servers
To enable compression in NGINX web server you will need to add the following code to the config file of your website
If you are using a W3 total cache plugin, you don’t need to add any code stuff in your .htaccess file. All you need to follow these steps:
- Go to WordPress dashboard
- Open the Performance tab from the left navigation
- Under the Browser cache check for Enable HTTP (gzip) compression
This will reduce the download time of the text-based files on your website.
Need help to configure the W3 Total cache plugin for the best results? Read:
Testing Gzip Compression
To check if the compression is working or not visit https://varvy.com/tools/gzip/, input your website URL and check compression. That’s so easy 🙂
At the end of this tutorial, you must be learned to enable Gzip compression on your website. For Apache web server users, I would recommend using mod_deflate in .htaccess file on the webserver. This will also speed up your WordPress blog.
Also, test your WordPress blog speed using speed testing tools like Pingdom (online service to check website speed). Not satisfied with your website speed? Read our tutorial How to Make the WordPress Blog Faster.