OSCache : CacheFilter
This page last changed on Apr 22, 2005 by lars t.
OSCache comes with a servlet filter that enables you to transparently cache entire pages of your website, and even binary files. Caching of binary files is extremely useful when they are generated dynamically, eg PDF files or images. Configuring the filterTo configure the filter, add something like the following to your web.xml file (obviously you will want to set the URL pattern to match only the content you want to cache; this example will cache all JSP pages): <filter> <filter-name>CacheFilter</filter-name> <filter-class>com.opensymphony.oscache.web.filter.CacheFilter</filter-class> </filter> <filter-mapping> <filter-name>CacheFilter</filter-name> <url-pattern>*.jsp</url-pattern> </filter-mapping> The default duration is one hour and the default scope for the cache is application scope. You can change these settings using initialization parameters. Parameter: timeThe time parameter sets the cache time (in seconds) for the content.Parameter: scopeThe scope parameter lets you set the scope to cache content in. Valid values for the scope are application and session.ExampleAs an example, the following settings would cache content for 10 minutes in session scope:<filter> <filter-name>CacheFilter</filter-name> <filter-class>com.opensymphony.oscache.web.filter.CacheFilter</filter-class> <init-param> <param-name>time</param-name> <param-value>600</param-value> </init-param> <init-param> <param-name>scope</param-name> <param-value>session</param-value> </init-param> </filter>
|
![]() |
Document generated by Confluence on Apr 30, 2005 22:37 |