Tomcat 7 GZIP compression not working

N.. picture N.. · May 20, 2013 · Viewed 33.3k times · Source

I have added the following lines in tomcat's conf/server.xml file to enable gzip compression but its not working. Pages are still uncompressesd.

 <Connector port="8080"
         compression="on"
         compressionMinSize="2048"
         noCompressionUserAgents="gozilla, traviata"
         compressableMimeType="text/html,text/xml,text/plain,text/css,
         text/javascript,text/json,application/x-javascript,
         application/javascript,application/json"/>

Any idea?

Answer

David Levesque picture David Levesque · May 21, 2013

If Tomcat is fronted by Apache on port 80, you will need to enable compression in Apache itself. The compression in Tomcat will only work if you access it directly on port 8080.