Tomcat enables Gzip compression and tomcat enables gzip
Recently, the end of the project optimizes the server configuration.
Today, record the process of enabling Gzip compression for tomcat. The method is simple. However, some tutorials on the Internet are not problematic, but there are some details.
The configuration is as follows:
In tomcat/conf/server. xml, find the following:
<Connector port="8081" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" />
To:
<Connector port="8082" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" compression="on" compressionMinSize="50" noCompressionUserAgents="gozilla, traviata" compressableMimeType="text/html,text/xml,text/javascript,text/css,text/plain,application/javascript"/>
1) compression = "on" enable the compression function
2) compressionMinSize = "50" enables the size of compressed output content. The default value is 2 kb.
3) noCompressionUserAgents = "gozilla, traviata" for the following browsers, compression is not enabled
4) compressableMimeType = "text/html, text/xml, text/css, text/plain, application/javascript" compressed resource type, other compressed items can be viewed in the browser, that is, the ContentType of the resource.
Taking chrome as an example:
Now enabled successfully,
Request a file of the type you have defined for compression. the table in the request header is successfully enabled:
So far, Gzip compression has been enabled successfully. There are some other optimization configurations that I will not write to myself.
Reference: http://tomcat.apache.org/tomcat-7.0-doc/config/http.html
Zemo hand, reproduced please indicate the source: http://blog.csdn.net/zemochen/article/details/42065363