HTTP compression can greatly improve the speed of browsing websites. Its principle is that after the client requests a webpage, the webpage file is compressed from the server and downloaded to the client. Compared with ordinary browsing process HTML, CSS, Javascript, Text, it can save about 40% of the traffic. More importantly, it can compress dynamically generated web pages including CGI, PHP, JSP, ASP, Servlet, SHTML, etc. The compression efficiency is amazing
. To use the gzip compression function under tomcat, you can use the Connector instance Add the following properties to:
Open the server.xml configuration file in the tomcat configuration
1) compression="on" enables Gzip compression
2) compressionMinSize="2048" enables compressed output content size, which defaults to 2KB
3) noCompressionUserAgents="gozilla, traviata" For the following browsers, Gzip compression is not enabled & <60;
4) compressableMimeType="text/html,text/xml" Gzip compression type
Configuration after Google:
maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
enableLookups="false" redirectPort="8443" acceptCount="100"
connectionTimeout="20000" disableUploadTimeout="true" URIEncoding="utf- 8"
compression="on" //This sentence and the following content are what tomat needs to add to enable the Gzip compression function!
compressionMinSize="2048" //Gzip compression is enabled when the file size is larger than this value
noCompressionUserAgents="gozilla,traviata"
compressableMimeType="text/html,text/xml,text/javascript,text/css,text/plain" />
Save after editing! Remember not to forget to restart tomcat, otherwise the gzip compression function will not take effect!