日期:2014-5-17 浏览次数:20154次

给Tomcat,Apache配置gzip压缩(HTTP压缩)功能

HTTP 压缩可以大大提高浏览网站的速度。相对于普通的浏览过程HTML ,CSS,Javascript , Text ,它可以节省40%左右的流量。更为重要的是,它可以对动态生成的,包括CGIPHP , JSP , ASP , Servlet,SHTML等输出的网页也能进行压缩,压缩效率惊人

一,对于Tomcat5.0以后的版本是支持对输出内容进行压缩的. 使用的是gzip压缩格式

下面是tomcat5.5.20 中的$tomcat_home$/conf/server.xml的原内容

1 clip_image001???? < Connector port ="80" maxHttpHeaderSize ="8192"
2 clip_image001?????????????? maxThreads ="150" minSpareThreads ="25" maxSpareThreads ="75"
3 clip_image001?????????????? enableLookups ="false" redirectPort ="8443" acceptCount ="100"
4 clip_image001?????????????? connectionTimeout ="20000" disableUploadTimeout ="true" URIEncoding ="utf-8" ? />
5 clip_image001???? <!-- Note : To disable connection timeouts, set connectionTimeout value
6 clip_image001???? to 0 -->
7 clip_image001???
8 clip_image001???? <!-- Note : To use gzip compression you could set the following properties :
9 clip_image001???
10 clip_image001?????????????? compression="on"
11 clip_image001??