web开发中可以通过gzip压缩页面来降低网站的流量,而gzip并不会对cpu造成大量的占用. resin中配置Gzip只需要在resin配置文件中加入一个filter即可,以下测试在resin-4.0.23非专业版上进行
1.在resin.xml中<web-app ...>下增加
<web-app xmlns="http://caucho.com/ns/resin"> <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>*.png</exclude-pattern> <include-pattern>/*</include-pattern> </url-pattern> </filter-mapping> </web-app>*有些文章说此方法只对于专业版本的resin有效,但经测试非专业版也适用
参考:
http://waynewan.com/archives/61
Expires header
<resin xmlns="http://caucho.com/ns/resin"> <logger name="com.caucho.server.cache" level="fine"/> #Debugging caching ... <host id="" root-directory="D:\works\deploy\mobile"> <web-app id="/" root-directory="."> <session-config> <reuse-session-id>true</reuse-session-id> <enable-cookies>false</enable-cookies> <enable-url-rewriting>true</enable-url-rewriting> </session-config> <cache-mapping url-pattern="*.gif" max-age="24h"/> <cache-mapping url-pattern="*.jpg" max-age="24h"/> <cache-mapping url-pattern="*.png" max-age="24h"/> <cache-mapping url-pattern="*.css" max-age="1h"/> <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>*.png,*.jpg,*.ico,*.gif,*.css</exclude-pattern> <include-pattern>/*</include-pattern> </url-pattern> </filter-mapping> </web-app> </host>
参考:
http://caucho.com/resin-4.0/admin/http-proxy-cache.xtp#Expires