我在我的tomcat7 server.xml中使用以下设置启用了压缩:
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443"
compression="on"
compressionMinSize="2048"
noCompressionUserAgents="gozilla, traviata"
compressableMimeType="text/html,text/xml,text/json,text/javascript,text/css,text/plain,
application/javascript,application/xml,application/xml+xhtml"
/>我已经检查过压缩现在是使用:http://www.whatsmyip.org/http-compression-test/打开的
然而,PageSpeed仍然报告有几个CSS/JS文件没有被压缩。例如,压缩http://www.mysite.co.uk/css/bootstrap.css可以节省109.5KiB (减少84%)。
发布于 2013-02-24 22:04:38
不是压缩的所有CSS/JS文件都比较大吗?这些可能是由"sendfile“发送,从而避免被压缩。
在文件中:
“注意:在使用压缩(节省带宽)和使用sendfile功能(节省CPU周期)之间有一种权衡。如果连接器支持sendfile功能,例如NIO连接器,使用sendfile将优先于压缩。其症状将是静态文件大于48 Kb将未经压缩发送。您可以通过设置连接器的useSendfile属性关闭sendfile,如下面所述,或者在默认的conf/web.xml或web应用程序的web.xml中更改DefaultServlet配置中的sendfile使用阈值。”
http://tomcat.apache.org/tomcat-6.0-doc/config/http.html
在您的配置中设置:
useSendfile="false"https://stackoverflow.com/questions/15057092
复制相似问题