Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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'm trying to enable gzip compression in my Apache server which is fronting a Tomcat instance using a connector. I tried several variants of the module configuration settings in my httpd.conf. Here is my latest attempt:

<IfModule mod_deflate.c>
SetOutputFilter DEFLATE
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html

DeflateCompressionLevel 9
SetEnvIfNoCase Request_URI \.(?:gif|png|jpg|jpeg)$ no-gzip dont-vary
Header append Vary User-Agent env=!dont-vary
DeflateFilterNote Input instream
DeflateFilterNote Output outstream
DeflateFilterNote Ratio ratio

LogFormat '"%r" %{outstream}n/%{instream}n (%{ratio}n%%)' deflate
CustomLog "/var/output/logs/deflate_log" deflate
ErrorLog "/var/output/logs/deflate_error_log"

I'm checking the response headers using Firebug and I verified that the request headers have Accept-Encoding: gzip deflate but every time, the Content-Encoding header is missing from response.

I tried adding the following line to httpd.conf, but it is giving an error that mod_deflate is a built-in module and cannot be loaded. I confirmed this by apachectl -t and it shows mod_deflate.c as compiled module.

LoadModule deflate_module /usr/lib/apache2/modules/

I've a Tomcat instance that is connected to Apache via AJP connector. When I debugged my servlets, I found that the response Content-Type I'm getting for my test script is application/javascript;charset=UTF-8. I initially was using AddOutputFilterByType directive and thought that the additional charset=UTF-8 part might be messing up the MIME type for Apache, but then it isn't working with SetOutputFilter DEFLATE also.

My custom logs for deflate show the following line repeatedly:

GET /myservlet HTTP/1.1" -/- (-%)

I don't understand why this isn't working. My Apache version is 2.0.63. Did anybody face similar issue? Is there anyway I can debug further and check what is going on within Apache? Perhaps enabling some debug logging?

Thanks, Venkat.

share|improve this question

You need to enable compression on Tomcat not on httpd for content served by Tomcat.

share|improve this answer
According to this post: link, it seems if Tomcat is fronted by Apache, we need to do it on Apache and not Tomcat. I tried enabling compression on Tomcat, but it isn't working either. – Venkat Mar 18 '14 at 1:23
As an additional note, Tomcat is compressing data if I access it directly on its own port 8080. But when I go through Apache, it is not compressing the data. – Venkat Mar 18 '14 at 1:28

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.