The method of Tomcat to open gzip is detailed

Source: Internet
Author: User

Open the Conf/server.xml file to see:

The code is as follows Copy Code

<!--Define a non-ssl http/1.1 Connector on port 8080-->
<connector
port= "8080" maxhttpheadersize= "8192"
maxthreads= "minsparethreads=" maxsparethreads= "75"
Enablelookups= "false" redirectport= "8443" acceptcount= "100"
connectiontimeout= "20000" disableuploadtimeout= "true"/>
<!--note:to Disable connection timeouts, set connectiontimeout value
to 0-->

<!--note:to Use gzip compression you could set the following properties:

Compression= "On"
Compressionminsize= "2048"
Nocompressionuseragents= "Gozilla, Traviata"
Compressablemimetype= "Text/html,text/xml"
-->

To use the gzip compression feature, you can add the following properties to the connector instance:

1) compression= "on" to turn on the compression function
2 compressionminsize= "2048" to enable compressed output content size, which defaults to 2KB
3 nocompressionuseragents= "Gozilla, Traviata" for the following browsers, do not enable compression &<60;
4) compressablemimetype= "Text/html,text/xml" compression type


After the modification is complete

The code is as follows Copy Code

<connector
port= "8080" maxhttpheadersize= "8192"
maxthreads= "minsparethreads=" maxsparethreads= "75"
Enablelookups= "false" redirectport= "8443" acceptcount= "100"
connectiontimeout= "20000" disableuploadtimeout= "true"
compression= "on"
Compressionminsize= "2048"
Nocompressionuseragents= "Gozilla,traviata"
Compressablemimetype= "Text/html,text/xml,text/javascript,text/css,text/plain"/>

That is, add the red part inside the connector.

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.