PS: First of all, I would like to thank SourceForge and those who contributed code selflessly. You are really great. Learn from you.
Is it because a large number of JS, JPG, and CSS files are introduced in the project that causes slow loading. So TK-filters is your gospel.
TK-Filters: http://download.csdn.net/detail/cl61917380/5449741 (smart people will Google)
1. Put the downloaded SRC Source Code and tk-filters.properties from the TK-filters project under the src directory in your web project, and then modify web. XML to add a filter, that's that simple.
2. Enable the filter you want in the tk-filters.properties. Example: gzipfilter. Enabled = true or cachefilter. Enabled = true
The related image is below. I think you can understand it at a Glance. If you don't understand it, you can leave a message.
The following is my test result to prove that this framework can be used:
In CSS, JPG, and JS file names respectively indicate their file sizes. For example, the actual size of the file 1028kb. JS is 1028kb!
When Gzip is disabled in the tk-filters.properties (gzipfilter. Enabled = false ),FirebugThe plug-in can easily see the size of the loaded file.
Before Gzip is enabled, the browser loads the file size and speed (the download size is 1 mb in the 1028kb. js file browser ):
After the gzip function is enabled, the browser loads the file size and speed (kb. js file browser displays the download size as 303.5kb ):
JSP:
<link rel="stylesheet" type="text/css" href="<%=path%>/css/2221kb.css"><script type="text/javascript" src="<%=path%>/js/1028kb.js"></script>
2. You can configure Tomcat directly in a more convenient way:
Reprinted from: http://www.cnblogs.com/codewater/articles/2228594.html
Open the conf/server. xml file and you can see:
<! -- Define a non-ssl http/1.1 Connector on port 8080 -->
<Connector
Port = "8080" maxhttpheadersize = "8192"
Maxthreads = "150" minsparethreads = "25" 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 cocould set the following properties:
Compression = "on"
Compressionminsize = "2048"
Nocompressionuseragents = "gozilla, Traviata"
Compressablemimetype = "text/html, text/XML"
-->
To use the gzip compression function, you can add the following attributes to the connector instance:
1) compression = "on" enable the compression function
2) compressionminsize = "2048" 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 & <60;
4) compressablemimetype = "text/html, text/XML" compression type
After modification
<Connector
Port = "8080" maxhttpheadersize = "8192"
Maxthreads = "150" minsparethreads = "25" 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"/>
Add the red part to connector.
Open the conf/server. xml file and you can see:
<! -- Define a non-ssl http/1.1 Connector on port 8080 -->
<Connector
Port = "8080" maxhttpheadersize = "8192"
Maxthreads = "150" minsparethreads = "25" 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 cocould set the following properties:
Compression = "on"
Compressionminsize = "2048"
Nocompressionuseragents = "gozilla, Traviata"
Compressablemimetype = "text/html, text/XML"
-->
To use the gzip compression function, you can add the following attributes to the connector instance:
1) compression = "on" enable the compression function
2) compressionminsize = "2048" 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 & <60;
4) compressablemimetype = "text/html, text/XML" compression type
After modification
<Connector
Port = "8080" maxhttpheadersize = "8192"
Maxthreads = "150" minsparethreads = "25" 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"/>
Add the red part to connector.