posts - 431,  comments - 344,  trackbacks - 0

          There are no code changes required for this - your application server should support servlet filtering already. Simply update your web.xml file, re-deploy and you should see the speedup right away.

          The basic steps you'll need to follow to configure Ehcache for web page caching are (note that these steps assume you already have Ehcache installed in your application):

          1. Configure a servlet page filter in web.xml
          2. Configure an appropriate cache in ehcache.xml
          3. Start (or re-start) your application

          The following settings should help you setup web caching for your application.

          Step 1 - Add a filter to your web.xml

          The first thing you'll need to do is add a filter to enable page caching.

          The following web.xml settings will enable a servlet filter for page caching:

          <web-app xmlns="http://java.sun.com/xml/ns/javaee"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
          http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd "
          version="2.5">
          <filter>
          <filter-name>SimplePageCachingFilter</filter-name>
          <filter-class>net.sf.ehcache.constructs.web.filter.SimplePageCachingFilter
          </filter-class>
          </filter>
          <!-- This is a filter chain. They are executed in the order below.
          Do not change the order. -->
          <filter-mapping>
          <filter-name>SimplePageCachingFilter</filter-name>
          <url-pattern>/*</url-pattern>
          </filter-mapping>
          </web-app>

          Step 2 - Configure an ehcache.xml

          The second step to enabling web page caching is to configure ehcache with an appropriate ehcache.xml.

          The following ehcache.xml file should configure a reasonable default ehcache:

          <ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:noNamespaceSchemaLocation="../../main/config/ehcache.xsd">
          <cache name="SimplePageCachingFilter"
          maxElementsInMemory="10000"
          maxElementsOnDisk="1000"
          eternal="false"
          overflowToDisk="true"
          timeToIdleSeconds="300"
          timeToLiveSeconds="600"
          memoryStoreEvictionPolicy="LFU"
          />
          </ehcache>

          Step 3 - Start your application server

          Now start your application server. Pages should be cached.

          posted on 2011-05-12 16:11 周銳 閱讀(847) 評論(0)  編輯  收藏 所屬分類: HTMLJava
          主站蜘蛛池模板: 彭山县| 弥勒县| 防城港市| 嫩江县| 临朐县| 鸡泽县| 丰城市| 高碑店市| 万年县| 泽州县| 通州市| 贺兰县| 巴林左旗| 罗源县| 耒阳市| 巴东县| 临武县| 池州市| 广丰县| 乌拉特前旗| 屏东县| 耿马| 萨嘎县| 甘泉县| 和平县| 渝北区| 东海县| 萨迦县| 枝江市| 任丘市| 团风县| 嘉义县| 海南省| 酒泉市| 白城市| 广州市| 洛隆县| 清河县| 朔州市| 苏州市| 颍上县|