Pergunta

Need Step-by-Step Overview for Compression on Tomcat 7 ... I've been at this for days. Particularly interested in compressing text/xml in response from a servlet, but would also like to test other compressions.

From my googling and reading, it seems like I only need to add a few lines to configure the http connector in server.xml (see below). But I'm checking on sites like webpagetest.org and not seeing any results (not even gzip in the response header). What more do I need? Filters? Use of GZip methods within my app? Specifying the servlet(s) for output compression in web.xml? I'll be more than happy to continue getting the details right and would be happy just now to be sure I know what all the necessary parts are.

    <Connector port="80" protocol="HTTP/1.1" 
           connectionTimeout="20000" 
           redirectPort="8443" 
          compression="on" 
          compressionMinSize="2048" 
          noCompressionUserAgents="gozilla, traviata" 
          compressableMimeType="text/html,text/xml,application/xml,text/javascript,text/css" />

UPDATE. SOLVED ... see comments under accepted answer below.

Foi útil?

Solução

Did you restart Tomcat after editing server.xml file ? Did you check the logs (logs/catalina.out) to see if there is any error on server startup ? (ie. typo in the config files)

compression="on"

should work.

Maybe webpagetest.org doesn't support gzip compression. Why don't you use Chrome Developper Tools (F12, you can see headers in the Network tab) ? or Firefox Web Console (Ctrl+Shift+K) ?

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top