gzip compression for jsf stuff

跟風遠走 提交于 2019-12-18 16:51:24

问题


I have an jsf application (mojarra 2.1.8, primefaces 3.3) running on tomcat 6. While analyzing the page in firebug with google page-speed, I realized I could optimize some stuff by gzip-compression.

Compressing the following resources with gzip could reduce their transfer size by 371,1KiB (74% reduction).

 Compressing http://localhost:8080/someApp/javax.faces.resource/jquery/jquery.js.jsf?ln=primefaces could save 72,5KiB (74% reduction).
 Compressing http://localhost:8080/someApp/javax.faces.resource/theme.css.jsf?ln=primefaces-aristo could save 53,4KiB (71% reduction).
 Compressing http://localhost:8080/someApp/javax.faces.resource/jsf.js.jsf?ln=javax.faces could save 49,6KiB (78% reduction). 
 ...

I already turned on compression in my server.xml

<Connector connectionTimeout="20000" port="8080" protocol="HTTP/1.1" redirectPort="8443"
      compression="on" 
      noCompressionUserAgents="gozilla, traviata"
      compressableMimeType="text/html,text/xml,text/plain,application/javascript,application/json,text/javascript"/>

But it doesn't compress the mentioned files listed above.

What else do I have to do to get compression working?

Jonny


回答1:


Your server.xml is all fine. Your concrete problem is most likely that you've edited the wrong server.xml file. In an IDE like Eclipse, the original Tomcat server installation is by default kept untouched. Instead, Eclipse creates a copy of all its configuration files in the Servers project and uses the workspace metadata to deploy the webapps and ultimately only the Tomcat server engine is been used from the Tomcat installation.

Make sure that you're editing the right server.xml file, the one in Servers project:

Tomcat's own /conf/server.xml file is only used when you start it outside Eclipse, or when you tell Eclipse to take full control over Tomcat installation instead. To do that, doubleclick the Tomcat server entry in Servers view and alter the Server Locations accordingly.



来源:https://stackoverflow.com/questions/10894779/gzip-compression-for-jsf-stuff

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