需要有关Tomcat压缩的循序渐进概述 [英] Need Step-by-Step Overview for Compression on Tomcat

查看:127
本文介绍了需要有关Tomcat压缩的循序渐进概述的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

需要有关Tomcat 7压缩的循序渐进概述...我已经有好几天了.对压缩servlet响应中的text/xml压缩特别感兴趣,但还想测试其他压缩方式.

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.

通过谷歌搜索和阅读,似乎我只需要添加几行即可在server.xml中配置http连接器(请参见下文).但是我正在检查像webpagetest.org这样的网站,却没有看到任何结果(甚至响应头中的gzip都没有).我还需要什么?过滤器?在我的应用程序中使用GZip方法?在web.xml中指定用于输出压缩的servlet?我将很乐意继续正确地获取详细信息,并且很高兴能确保我知道所有必要的部分.

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.

推荐答案

在编辑server.xml文件后是否重新启动了Tomcat? 您是否检查了日志(logs/catalina.out)以查看服务器启动时是否存在任何错误? (即配置文件中的错字)

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"

应该工作.

也许webpagetest.org不支持gzip压缩.为什么不使用Chrome开发人员工具(F12,您可以在网络"标签中看到标题)?或Firefox Web控制台(Ctrl + Shift + K)吗?

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

这篇关于需要有关Tomcat压缩的循序渐进概述的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆