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 --silent \
--write-out "%{size_download}\n" --output /dev/null

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

~ $ curl --silent \
-H "Accept-Encoding: gzip,deflate" \
--write-out "%{size_download}\n" --output /dev/null

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