Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have put the following in my http.conf file:

# mod_deflate configuration
<IfModule mod_deflate.c>

# Restrict compression to these MIME types
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/x-javascript
AddOutputFilterByType DEFLATE text/javascript
AddOutputFilterByType DEFLATE text/css

# Level of compression (Highest 9 - Lowest 1)
DeflateCompressionLevel 9

# Netscape 4.x has some problems.
BrowserMatch ^Mozilla/4 gzip-only-text/html

# Netscape 4.06-4.08 have some more problems
BrowserMatch ^Mozilla/4\.0[678] no-gzip

# MSIE masquerades as Netscape, but it is fine
BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html

<IfModule mod_headers.c>
# Make sure proxies don't deliver the wrong content
Header append Vary User-Agent env=!dont-vary


My content doesn't return with a Content-Encoding of type gzip, but I find myself getting a lot more 304s and the Etag is appended with a +gzip suffix. Is mod_deflate actually doing its job? (Sorry about the n00b-ishness)

share|improve this question
up vote 9 down vote accepted

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'
share|improve this answer
like I said, it doesn't return a Content-Encoding header at all – Jayraj Nov 27 '11 at 7:11

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 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

Use cURL as mentioned by Michael Steinfeld to verify.

share|improve this answer
apache 2.4 upgrade doc seems to indicate that it will automagically determine whether or not to gzip a given resource: "mod_deflate will now skip compression if it knows that the size overhead added by the compression is larger than the data to be compressed" -- – virtualeyes Jan 15 '13 at 0:27
In httpd-2.4 this AddOutputFilterByType directive is corrected, un-deprecated and moved to filter_module. – Tometzky May 6 '13 at 12:42

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


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

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.