How to check that server compression is working

Not sure that you properly configured resource compression at your web server or just wanna play with compression settings or check that all resources are compress as it intended?
The easies way to check it is via simple CLI command:

At first determine the size of raw resource:

~ $ curl https://yoursite.com/path/resource.js --silent \
--write-out "%{size_download}\n" --output /dev/null
170564

Now add the specific Accept-Encoding header telling the server that client supports compression:

~ $ curl https://yoursite.com/path/resource.js --silent \
-H "Accept-Encoding: gzip,deflate" \
--write-out "%{size_download}\n" --output /dev/null
41404

Getting different numbers for same static document would mean that your compression works as intended.
And the ratio between these two numbers would show compression efficiency.

Leave a Reply