Public cache filter ver. 1.2


This is a Java servlet filter (as per Servlet API 2.3). This filter lets you define public cache header. This header instructs the proxies that your resources are cacheable and allows proxies, gateways and the client browser to cache the resources to reduce the bandwidth consumption to the server.

How to use it:

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

b) describe this filter in your web.xml file.
 


<filter>
  <filter-name>PublicCacheFilter</filter-name>
  <filter-class>com.cj.expire.PublicCacheFilter</filter-class>
</filter>

c) describe a mapping for this filter in web.xml.
 


<filter-mapping>
  <filter-name>PublicCacheFilter</filter-name>
  <url-pattern>*.gif</url-pattern>
</filter-mapping>

in this case filter will be on for the each .gif file. This trick lets you declare cacheable images for your web application.

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>PublicCacheFilter</filter-name>
  <filter-class>com.cj.expire.PublicCacheFilter</filter-class>
  <init-param>
    <param-name>exclude</param-name>
    <param-value>/main.htm</param-value>
  </init-param>
</filter>

   For downloading:

    Filter:  pcacheflt.jar
 

 ©  Coldbeans     Comments?

See also JSOS - the largest collection of servlets and filters.

Also in Coldtags: