Need Step-by-Step Overview for Compression on Tomcat

北战南征 提交于 2019-12-02 04:43:11

问题


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.


回答1:


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



来源:https://stackoverflow.com/questions/16690321/need-step-by-step-overview-for-compression-on-tomcat

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!