This is a Java servlet filter (as per Servlet API 2.3). This filter lets you define Expires and max-age headers for your output pages. So with this filter you will be able to define a caching time for your pages. The page will be cached until that time expires. How to use it: a) download expflt.jar and save it in WEB-INF/lib b) describe this filter in your web.xml file. There are two one optional parameters. Parameter expires describes
a caching time for your pages in seconds. By default it is 3600 (1 hour).
<filter> <filter-name>ExpiresFilter</filter-name> <filter-class>com.cj.expire.ExpiresFilter</filter-class> </filter> or
<filter> <filter-name>ExpiresFilter</filter-name> <filter-class>com.cj.expire.ExpiresFilter</filter-class> <init-param> <param-name>expires</param-name> <param-value>1800</param-value> </init-param> </filter> 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>ExpiresFilter</filter-name> <filter-class>com.cj.expire.ExpiresFilter</filter-class> <init-param> <param-name>exclude</param-name> <param-value>/main.htm</param-value> </init-param> </filter> c) describe a mapping for this filter in web.xml.
<filter-mapping> <filter-name>ExpiresFilter</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 cache images for your web application. For downloading: Filter: expflt.jar
See also JSOS - the largest collection of servlets and filters.
|
Also in Coldtags:
|