How to tell if mod_deflate is actually working?

Solution 1:

What do the headers tell you, if it is not returning "content-encoding: gzip" it's probably not working.. you can test as follows:

curl -I -H 'Accept-Encoding: gzip,deflate' http://yoursite.com/somefile

Solution 2:

The apache docs for AddOutputFilterByType indicate this directive is deprecated in Apache httpd 2.1 and later and it doesn't always work well if Apache can not determine the mime type.

I would suggest enabling compressing by using something like the following as a starting point and then add all the browser tweaks and compression levels back in. Obviously, you may want to double check httpd.conf to make sure it's actually loading mod_deflate.so as well:

<Location />
    SetOutputFilter DEFLATE
    # Don't compress images
    SetEnvIfNoCase Request_URI \.(?:gif|png|jpg|jpeg)$ no-gzip dont-vary
    Header append Vary User-Agent env=!dont-vary
</Location>

Use cURL as mentioned by Michael Steinfeld to verify.

Solution 3:

Can't add acomment as I don't have enough reputation therefore I am writing this as an answer.

The original answer by Michael Steinfeld was outputting the following error (on Windows Command Prompt)

curl: (6) Could not resolve host: gzip,deflate'

I solved it by removing the space after the colon:

curl -I -H 'Accept-Encoding:gzip,deflate' http://yoursite.com/somefile

Solution 4:

With LogLevel set to debug, mod_deflate will log its debug messages to ErrorLog. Every resource that is being compressed gets logged out there. You can see if mod_deflate is working in real-time with

tail -f /path/to/error-log | grep deflate

e.g.

[Wed Apr 22 05:37:49.742615 2015] [deflate:debug] [pid 22627] mod_deflate.c(849): [client 127.0.0.1:55667] AH01384: Zlib: Compressed 10700 to 2637 : URL /web/js/common.js, referer: http://localhost/index.php