tomcat开启了gzip性能优化

所谓的Gzip就是一种压缩格式。它在网络上的工做原理通俗说法就是客户端向服务器发送请求,而服务器将请求结果通过压缩后再返回到客户端,这样作的效果就是使返回的数据较不处理的数据更小,返回到客户端的时间更短,减小客户端等待的时间。若是想获得更专业的解答,可参考百度百科的关于Gzip的解释,网址是:http://baike.baidu.com/view/966625.htm。javascript

<Connector port="9090" protocol="HTTP/1.1"
connectionTimeout="20000"?
URIEncoding="UTF-8"
redirectPort="8443"
compression="on"
compressionMinSize="2048"
noCompressionUserAgents="gozilla,traviata"
compressableMimeType="text/html,text/xml,text/JavaScript,text/css,text/plain,application/javascript"
 />css

其中:html

●compression="on" 打开压缩功能java

●compressionMinSize="2048"启用压缩的输出内容大小,默认为2KBweb

●noCompressionUserAgents="gozilla,traviata" 对于如下的浏览器,不启用压缩浏览器

●compressableMimeType="text/html,text/xml,text/JavaScript,text/css,text/plain" 哪些资源类型须要压缩服务器

若是遇到以下问题:网络

Note: There is a tradeoff between using compression (saving your bandwidth) and using the sendfile feature (saving your CPU cycles). If the connector supports the sendfile feature, e.g. the NIO connector, using sendfile will take precedence over compression.?The symptoms will be that static files greater that 48 Kb will be sent uncompressed.?You can turn off sendfile by setting useSendfile attribute of the connector, as documented below, or change the sendfile usage threshold in the configuration of the DefaultServlet in the default conf/web.xml or in the web.xml of your web application.app

意思是大于48Kb的文件为了节省cpu就不压缩而采用别的处理方法。添加useSendfile="false"后,能够被正常压缩了。xml

相关文章
相关标签/搜索