terminal-logo-smallThis is a quick method with using cURL to check that Apache Compression with mod_gzip and mod_deflate is working. Only the remote server headers are needed.

Check that the Apache Compression is Working

Get headers


curl -I -H 'Accept-Encoding: gzip,deflate' http://www.if-not-true-then-false.com

-I option which will make just HEAD request to server and get headers.
-H option add header for accecpt content-encondig gzip and deflate.

Check headers


### Working ###
[...]
Content-Encoding: gzip
[...]
### Working ###
[...]
Content-Encoding: deflate
[...]
### Not working ###
[...]
[...]

If gzip or deflate found from headers then compression is working.

Simple bash function to check Apache compression

Create function (add following to ~/.bashrc)


function check_compression {
  curl -I -H 'Accept-Encoding: gzip,deflate' $1 |grep "Content-Encoding"
}

Function usage


[root ~]> check_compression http://www.if-not-true-then-false.com/wp-content/themes/snowblind/style.css
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0  3203    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
Content-Encoding: gzip

[root ~]> check_compression http://www.if-not-true-then-false.com/wp-content/plugins/wp-minify/min/?f=/wp-content/themes/snowblind/style.css
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0  2165    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
Content-Encoding: deflate