oscache / docs / filter.html

<title>Caching Content with the CacheFilter</title>

<body bgcolor="#FFFFFF">

<p><b>OSCache</b> 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.</p>

<p>To 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):


<p>The default duration is one hour and the default scope for the cache is application scope. You
can change these settings using initialization parameters. The <code>time</code> parameter sets
the cache time (in seconds), while the <code>scope</code> parameter lets you set the scope. Valid
values for the scope are <code>application</code> and <code>session</code>.</p>

<p>As an example, the following settings would cache content for 10 minutes in session scope:

<p>Note that the filter will only cache content that has a status of 200 (<code>HttpServletResponse.SC_OK</code>).</p>
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.