tomcat6的gzip传输

    <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默认3text/html,text/xml,text/plain

<!--EndFragment-->

http://tomcat.apache.org/tomcat-5.5-doc/config/http.html

写道
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里的结果


tomcat6的gzip传输_第1张图片
 
tomcat6的gzip传输_第2张图片
 

<!--EndFragment--> <!--EndFragment-->

你可能感兴趣的:(JavaScript,tomcat,jsp,css,Firebug)