How to Check Whether Gzip Compression is Working?
We often have questions about testing for Gzip compression after someone tests their landing page. Gzip is most likely working. The issue is that the landing page comprises several types of data, and .htaccess rules may have only defined certain data to be compressed. If not everything on that landing page is compressed, it may return an erroneous result stating that compression is not enabled. We’ll explain how to enable Gzip compress and how to test and confirm that it is enabled in this article.
How To Enable Gzip Compression (mod_deflate)
To enable ‘Gzip compression’, you must enable the mod_deflate Apache module and then add .htaccess rules like these listed below,
To test whether your Apache installation had mod_deflate enabled, run the following command as root via SSH,
httpd -M | grep deflate
[root@host ~]# httpd -M | grep deflate deflate_module (shared)
Checking Gzip Compression With Curl
You can also use wget to compare a compressed file download to a non-compressed file download.
First, download the compressed file,
wget --header='Accept-Encoding: gzip' http://domain.com/index.html
Next, download the non-compressed file,
Next, compare the amount of time it took overall for the compressed file and the non-compressed files to download so that you can see how much time is saved when using compression to serve files.
Additionally, you can also ask wget to save the headers,
wget --save-headers http://domain.com
You can then check the downloaded file for the headers and confirm that compression is enabled for that mime-type.
Now that we’ve gone over how to check whether Gzip compression is working or not. We have covered the two methods to check to check Gzip compression on the server (wget & curl). Knownhost wants your sites to perform optimally, so this module is enabled on our servers by default.
KnownHost offers 365 days a year, 24 hours a day, all 7 days of the week best in class technical support. A dedicated team ready to help you with requests should you need our assistance. You’re not using KnownHost for the best webhosting experience? Well, why not? Check with our Sales team to see what can KnownHost do for you in improving your web hosting experience.