<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443"
compression="on"
compressionMinSize="2048"
noCompressionUserAgents="gozilla, traviata"
compressableMimeType="text/html,text/xml,text/javascript,text/css,text/plain,image/gif,image/jpeg,image/png"
/>
Tomcat6里面没有这段注释,从tomcat5.5里面copy过来的
compressionMinSize 2048 意味着2k以上才进行压缩
compressableMimeType默认3个text/html,text/xml,text/plain
<!--EndFragment-->
http://tomcat.apache.org/tomcat-5.5-doc/config/http.html
但是一般要加上
text/javascript,text/css,image/gif,image/jpeg,image/png
是mimetype,是jpeg不是jpg
如果是jsp的话,主流的浏览器会自动解压,jsp里不用做任何多余设置,如果是java程序读的话,需要设置
method.addRequestHeader("accept-encoding", "gzip,deflate");
在firebug里的结果
<!--EndFragment--> <!--EndFragment-->