Tomcat optimized to enable gzip Web compression speeds up website access

Source: Internet
Author: User

Now with the search engine upgrade, now more focus on the site user experience. For the majority of webmaster friends, the speed of the site is even more important than the content. Because if the customer visit your website has been open, even if the content of the site is excellent, I believe not many people will wait patiently. Therefore, it is very necessary and important to improve the speed of website visit. Today I would like to share with you how to open the Tomcat Server Gzip Web compression function, to improve the speed of website access.

First, we introduce the GZIP compression technology and the advantages

The so-called gzip compression technology was first created by Jean-loup Gailly and Mark Adler for file compression on UNIX systems. We often use files with the. gz suffix in Linux, which are in gzip format. Nowadays it has become a very popular data compression format, or a file format, used on the Internet. GZIP encoding on the HTTP protocol is a technique used to improve the performance of Web applications. High-traffic Web sites often use gzip compression technology to make users feel faster. This generally refers to the WWW server installed in a feature, when someone to access the site in this server, the server of this feature will compress the content of the Web page is transmitted to the visiting Computer browser display. Generally, the content of plain text can be compressed to 40% of the original size. So the transmission is fast, the effect is that you click the URL will be displayed quickly, of course, this will increase the load of the server.

Next, let's talk about how to turn on the Gzip Web compression feature of the Tomcat server

For Tomcat5.0 later versions are supported to compress the output content, using the gzip compression format

To modify%tomcat_home%/conf/server.xml, the first connector node of the file, the node that needs to be modified is as follows:

<connector port= "protocol=" http/1.1 "

connectiontimeout= "20000"

redirectport= "8443"/>

The modified code is as follows:

<connector port= "protocol=" http/1.1 "

connectiontimeout= "20000"

Redirectport= "8443" uriencoding= "Utf-8"

Compression= "on" compressionminsize= "2048"

Nocompressionuseragents= "Gozilla, Traviata"

Compressablemimetype= "Text/html,text/xml,text/javascript,

Text/css,text/plain "/>

The following attributes are added

1, compression= "on" to open the compression function

2, compressionminsize= "2048″ Enable compressed output content size, which defaults to 2KB

3, nocompressionuseragents= "Gozilla, Traviata" need to exclude the browser;

4, compressablemimetype= "Text/html,text/xml,text/javascript,text/css,text/plain" compression type

After the modification, restart the next Tomcat, and finally to detect the site.

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Tomcat optimized to enable gzip Web compression speeds up website access

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.