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

I'm developing a web application locally on my system, serving it using Tomcat (tomcat-7.0.52). In production, I want to front the Tomcat with an Apache httpd (Apache/2.2.15).

This works and I managed to configure caching as needed. Now I want to configure compression, but it seems that a can't get Apache httpd to modify the response it got from Tomcat.

But as I read here, this is the preferred way of doing to. mod_jk compression is only between httpd and Tomcat and if I want to configure compression directly in Tomcat, I'd need an extra servlet for it.

I have the following line in my vhost-file to enable compression of static and httpd-served content:

 #SetOutputFilter DEFLATE
 AddOutputFilterByType DEFLATE text/plain text/html application/json text/xml text/css text/javascript

Enabling the 1st line didn't change anything for me.

I pass these requests to Tomcat using mod_jk:

<IfModule mod_jk.c>
 JkMount /myapp/j_security_check worker1
 JkMount /myapp/*.jsp worker1
 JkMount /myapp/DataSourceLoader worker1
 JkMount /myapp/ServletLogin worker1

Using Firebug I can see that the mime-type of the Tomcat-returned requests is

/myapp/j_security_check: "text/plain; charset=UTF-8" (with the space)
/myapp/*.jsp: "text/plain; charset=UTF-8" (with the space)
/myapp/DataSourceLoader: "application/json;charset=UTF-8"  (without space)

Because of the spaces I can't add to AddOutputFilterByType and as I also have the mime-types without the UTF-8 and I also tried with just SetOutputFilter, I think that these directives do not manipulate the Tomcat answer at all.

So my questions are:

  1. What's the best suggested solution? Tomcat compression or Apache httpd compression? (According to gzip compression using mod_deflate apache with tomcat (which redirects here: it should be done in httpd)

  2. How do I enable Apache httpd-compression for mod_jk results (perhaps from JBoss and not Tomcat)?

  3. Perhaps related: How do I modify caching headers from mod_jk results in Apache httpd?

Thank you!

share|improve this question

1 Answer 1


I agree with #1 in that compression can be handled with apache or another web server.

Here are my thoughts:

  1. I use apache mod_proxy or nginx in front of tomcat. This allows me to handle SSL, compression and static content if needed. I have started to move to nginx to replace apache on the front end.
  2. mod_deflate for apache or nginx ngx_http_gzip_module
  3. You can handle all the caching rules in tomcat or apache. It depends on what rules you want.
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.