1. apache2.2 和 tomcat6 javascript
2. tomcat6的server.xml文件配置: css
< Connector port ="80" maxHttpHeaderSize ="8192"
maxThreads ="150" minSpareThreads ="25" maxSpareThreads ="75"
enableLookups ="false" redirectPort ="8443" acceptCount ="100"
connectionTimeout ="20000" disableUploadTimeout ="true" compression="on" compressableMimeType="text/html,text/xml,text/css,text/javascript,image/gif,image/jpeg,image/png,image/img,application/x-javascript,text/plain,application/json" URIEncoding ="utf-8" />
1) compression="on" 打開壓縮功能
2) compressionMinSize="2048" 啓用壓縮的輸出內容大小,這裏面默認爲2KB
3) noCompressionUserAgents="gozilla, traviata" 對於如下的瀏覽器,不啓用壓縮
4) compressableMimeType="text/html,text/xml" 壓縮類型 html
3. apache2.2的httpd.conf配置: java
1)針對Apache2.0以前的版本,它本來是不支持的,不過能夠經過添加第三方的module_gzip模塊來啓用
2)針對Apache2.0及以後的版本,Apache 提供支持, 不過不叫gzip,而叫mod_deflate apache
開啓三個模塊: json
在Apache的配置文件中找到下面兩行,將註釋#去掉,重啓。
LoadModule deflate_module modules/mod_deflate.so
LoadModule expires_module modules/mod_expires.so
LoadModule headers_module modules/mod_headers.so
瀏覽器
增長: tomcat
<IfModule expires_module>
ExpiresActive On
ExpiresDefault "access plus 12 month"
ExpiresByType text/html "access plus 12 months"
ExpiresByType text/css "access plus 12 months"
ExpiresByType image/gif "access plus 12 months"
ExpiresByType image/jpeg "access plus 12 months"
ExpiresByType image/jpg "access plus 12 months"
ExpiresByType image/png "access plus 12 months"
ExpiresByType image/img "access plus 12 months"
EXpiresByType application/x-shockwave-flash "access plus 12 months"
EXpiresByType application/x-javascript "access plus 12 months"
ExpiresByType video/x-flv "access plus 12 months"
</IfModule>
<IfModule mod_deflate.c>
SetOutputFilter DEFLATE
AddOutputFilterByType DEFLATE text/html text/css image/gif image/jpeg image/png application/x-javascript
</IfModule>
或: app
<IfModule deflate_module>
SetOutputFilter DEFLATE
AddOutputFilterByType DEFLATE text/html text/css image/gif image/jpeg image/png application/x-javascript
</IfModule> ide