Tomcat enables Gzip compression and tomcat enables gzip

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.