Tomcat6 tomcat7 configure gzip to solve the problem of too many ext-all.js files

Source: Internet
Author: User

Do the project used extjs4.0 framework, but the introduction of js, css files too much and big, especially ext-all.js, 1.2 M, the page Initialization is very slow and consumes bandwidth, because the use of the server is tomecat, finally, we will use gzip with tomecat configuration to compress the request file. The configuration steps are as follows:

1: Find the server. xml file under the conf file of tomecat, open it, and find

<Connector port = "8080" protocol = "HTTP/1.1"
ConnectionTimeout = "20000"
RedirectPort = "8443" type = "regxph" text = "yourobjectname"/>

2: Add attributes to the tag.

Compression = "on"
CompressionMinSize = "2048"
NoCompressionUserAgents = "gozilla, traviata"
CompressableMimeType = "text/html, application/xml, application/javascript, text/css, application/json, image/png, image/gif, image/jpg"

Note: The value in compressableMimeType is the file that requires tomecat compression. For example, application/javascrip is used to compress the published js file. Other files can be compressed on the web in conf. found in xml, as shown in

<Mime-mapping>
<Extension> css </extension>
<Mime-type> text/css </mime-type>
</Mime-mapping>

Shows how to configure css compression.

Maybe we will be curious, ext-all.js is not already compressed JavaScript, has no comments and spaces, why can continue to compress? For example, gzip compression can be used to modify the variable name and define it with the least number of characters as much as possible. This can also greatly reduce the number of characters.

How can I check whether the compression takes effect? For example, use firedebug of firefox as follows:

Request before compression:

After compression:

Through comparison, we found that the size of js files and css files significantly changed.

Related Article

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.