服务器上使用gzip压缩

在resin服务器上使用gzip压缩
web开发中可以通过gzip压缩页面来降低网站的流量,而gzip并不会对cpu造成大量的占用,只是几个百分点而已,但是对于页面却能压缩40%以上,非常划算。
resin服务器具体配置方法:
修改resin/conf/resin.conf文件,在<web-app>中添加以下配置代码:


<filter filter-name="gzip"
filter-class="com.caucho.filters.GzipFilter">
<init>
<use-vary>true</use-vary>
</init>
</filter>

<filter-mapping filter-name="gzip">
<url-pattern>
<exclude-pattern>*.pdf</exclude-pattern>
<include-pattern>/*</include-pattern>
</url-pattern>
</filter-mapping>

在tomcat中:
<Connector port="8081" 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 could set the following properties :

compression="on"
compressionMinSize="2048"
noCompressionUserAgents="gozilla, traviata"
compressableMimeType="text/html,text/xml"
-->

<!-- Define a SSL HTTP/1.1 Connector on port 8443 -->
只要把compression="on"
compressionMinSize="2048"
noCompressionUserAgents="gozilla, traviata"
compressableMimeType="text/html,text/xml"加上。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值