Cache On filter ver. 1.3


This is a Java servlet filter (as per Servlet API 2.3). This filter lets you deploy client side cache. In other words any resource covered by this filter will be cached on client's web browser's cache. You can use this technique for example for images, big static data etc.

How to use it:

a) download cacheonflt.jar and save it in WEB-INF/lib

b) describe this filter in web.xml. You have to provide an initial parameter age. This parameter describes a caching time in seconds. E.g.:
 


<filter>
  <filter-name>CacheOnFilter</filter-name>
  <filter-class>com.cj.cacheon.CacheOnFilter</filter-class>
  <init-param>
    <param-name>age</param-name>
    <param-value>600</param-value>
  </init-param>
</filter>

d) describe a mapping for this filter in web.xml. E.g.:
 


<filter-mapping>
  <filter-name>CacheOnFilter</filter-name>
  <url-pattern>/images/*</url-pattern>
</filter-mapping>

in this example filter will be on for the each file in /images subdirectory. It means that files from this path will be cached on the client side for 10 minutes (600 seconds).

Also you may exclude some of your files from the processing. Parameter exclude contains a commas separated list of files excluded from the processing. E.g.:
 


<filter>
  <filter-name>CacheOnFilter</filter-name>
  <filter-class>com.cj.cacheon.CacheOnFilter</filter-class>
  <init-param>
    <param-name>exclude</param-name>
    <param-value>/main.htm</param-value>
  </init-param>
</filter>

   For downloading:

    CacheOn package:  cacheonflt.jar
 

 ©  Coldbeans     Comments?

See also Coldtags suite - the largest collection of custom JSP tags.

Also in JSOS: