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 >
      <web-app >
        <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

相关文章:

  • 2022-12-23
  • 2021-11-17
  • 2021-05-06
  • 2022-01-16
  • 2021-11-25
  • 2021-11-22
  • 2021-10-11
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-03-08
  • 2022-12-23
  • 2022-02-12
  • 2021-10-11
相关资源
相似解决方案