Commits

Anonymous committed 0fd276a

new example with the new parameters disableCacheOnMethods and oscache-properties-file of the CacheFilter

Comments (0)

Files changed (5)

src/java/com/opensymphony/oscache/web/filter/CacheFilter.java

 
     /**
      * <b>disableCacheOnMethods</b> - Defines the http method name for which cacheing should be disabled.
-     * The default value is <code>null</code> for cacheing all request without regarding the method name.
+     * The default value is <code>null</code> for cacheing all requests without regarding the method name.
      * @link http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/servlet/http/HttpServletRequest.html#getMethod()
      * @param disableCacheOnMethods the list of http method names for which cacheing should be disabled
      * @since 2.4

src/webapp/WEB-INF/classes/oscache-cachefilter-disableCacheOnMethods.properties

+# CACHE KEY
+cache.key=__oscache_cachefilter_disableCacheOnMethods
+
+# CACHE LISTENERS
+cache.event.listeners=com.opensymphony.oscache.extra.ScopeEventListenerImpl
+
+# CACHE SIZE
+cache.capacity=10

src/webapp/WEB-INF/web.xml

         <filter-class>com.opensymphony.oscache.web.filter.CacheFilter</filter-class>
     </filter>
 
+    <filter>
+        <filter-name>CacheFilter-disableCacheOnMethods</filter-name>
+        <filter-class>com.opensymphony.oscache.web.filter.CacheFilter</filter-class>
+        <init-param>
+            <param-name>time</param-name>
+            <param-value>60</param-value>
+        </init-param>
+        <init-param>
+            <param-name>disableCacheOnMethods</param-name>
+            <param-value>POST,PUT,DELETE</param-value>
+        </init-param>
+        <init-param>
+            <param-name>oscache-properties-file</param-name>
+            <param-value>/oscache-cachefilter-disableCacheOnMethods.properties</param-value>
+        </init-param>
+    </filter>
+
     <filter-mapping>
         <filter-name>CacheFilter</filter-name>
         <url-pattern>/filter/*</url-pattern>
     </filter-mapping>
-
+    
+    <filter-mapping>
+        <filter-name>CacheFilter-disableCacheOnMethods</filter-name>
+        <url-pattern>/filter2/*</url-pattern>
+    </filter-mapping>
+    
     <listener>
         <listener-class>com.opensymphony.oscache.web.CacheContextListener</listener-class>
     </listener>
     </servlet-mapping>
 
     <session-config>
-        <session-timeout>5</session-timeout>
+        <session-timeout>10</session-timeout>
     </session-config>
 
 </web-app>

src/webapp/filter2/filterTestDisableCacheOnMethods.jsp

+<%@ page import="java.util.*" %>
+<head>
+<title>Filter Test Disable Cache On Methods Page</title>
+<style type="text/css">
+body {font-family: Arial, Verdana, Geneva, Helvetica, sans-serif}
+</style>
+</head>
+<body>
+<a href="<%= request.getContextPath() %>/">Back to index</a><p>
+<hr>
+<b>This is the POST vs. GET cache content example (refresh time = 60 seconds).</b><br>
+<br>
+<b>Time this page was last refreshed: </b>: <%= new Date() %><br><br>
+<b>Current Time Millis</b>: <%= System.currentTimeMillis() %><br>
+<br>
+<a href="filterTestDisableCacheOnMethods.jsp">GET with the cache</a><p>
+<br>
+<br>
+<form action="filterTestDisableCacheOnMethods.jsp" method="post">
+	<input type="submit" value="POST without the cache">
+</form>
+</body>
+</html>

src/webapp/index.html

 <li><a href="cronTest.jsp">cronTest.jsp</a></li>
 <li><a href="silentTest.jsp">silentTest.jsp</a></li>
 <li><a href="filter/filterTest.jsp">filter/filterTest.jsp</a></li>
+<li><a href="filter2/filterTestDisableCacheOnMethods.jsp">filter2/filterTestDisableCacheOnMethods.jsp</a></li>
 <li><a href="oscacheTestMultipleTagNoKey.jsp">oscacheTestMultipleTagNoKey.jsp</a></li>
 <li><a href="cacheServlet?refreshPeriod=10">OSCache Test Servlet</a></li>
 </ul>