Tomcat配置使用gzip,在server.xml中
<Connector port="9098" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" URIEncoding="UTF-8" compression="on" compressionMinSize="2048" noCompressionUserAgents="gozilla,traviata" compressableMimeType="text/html,text/xml,text/javascript,application/javascript,text/css,text/plain"/>
compression="on" 打开压缩功能
compressionMinSize="2048" 启用压缩的输出内容大小,这里面默认为2KB
noCompressionUserAgents="gozilla, traviata" 对于以下的浏览器,不启用压缩;
compressableMimeType="text/html,text/xml" 压缩类型
重启tomcat即可。