tomcat启用gzip压缩

在tomcat的server.xml找到Connector元素,增加如下属性即可:

compression="on"
compressionMinSize="2048"
noCompressionUserAgents="gozilla, traviata"
compressableMimeType="text/html,text/xml,text/javascript,text/css,text/plain"

添加完以后的完整Connector元素如下:


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

你可能感兴趣的:(tomcat启用gzip压缩)