Below we’ll give a further breakdown of why using Gzip compression is so useful, how to enable it on different web servers, and how to check if it is working.
Why use Gzip compression?
As noted in Patrick Sexton’s article, ‘compressing HTML and CSS files with Gzip normally saves 50-70% of the file size’. This means that users have smaller files to download when visiting your pages, so the loading time will be quicker, resulting in a better experience for the users. As all modern browsers understand and accept Gzip compressed files, there’s almost no reason not to do it!
While it could be argued that there are some downsides to using Gzip compression, in general the pros outweigh the cons. For example, while it does take time for the browser to unzip files when transferred, this is normally still shorter than the time saved by providing a smaller file for download.
With this in mind, here are the different ways you can enable Gzip compression for different web servers.
Gzip compression for different web servers
The way to enable Gzip compression differs slightly depending on whether you are using htaccess, Apache, Nginx, or other web servers.
For htaccess and Apache, you need to add a set of code to your .htaccess file (which can be found through the file manager) – Varvy gives a handy copy of the code you can use. In the same article they also provide the code you can use for Nginx, which should be added to your config file.
For other options, such as Gzip compression specific to WordPress (which can be done through the WordPress control panel), Gift of Speed gives a good breakdown of the code and process that can be used.
How to check if your Gzip compression works
There are lots of easy to use online tools that can help you check whether your Gzip compression enabling has worked (or if it your site was even running it already). With both Varvy’s and Check Gzip Compression’s tools, all you need to do is enter your page’s URL. They will then let you know if it is working, and give you details on how much your file sizes have been reduced.