The filter annotation as follows:
Code: Select all
@WebFilter(filterName = "CashingServlet", urlPatterns = {
//js files
"*.js",
//css files
"*.css",
//image files
"*.png",
"*.jpg",
"*.gif",
"*.ico"
}, dispatcherTypes = {DispatcherType.FORWARD, DispatcherType.ERROR, DispatcherType.REQUEST, DispatcherType.INCLUDE})
Code: Select all
HttpServletResponse res = (HttpServletResponse) response;
Calendar inOneMonth = Calendar.getInstance();
inOneMonth.add(Calendar.MONTH, 1);
res.setHeader("Cache-Control", "max-age=25920000, private");//300 days
res.setDateHeader("Expires", inOneMonth.getTimeInMillis());//Expires does not work (header not set)
Code: Select all
X-Powered-By Servlet/3.0, JSF/2.0
Server GlassFish Server Open Source Edition 3.0.1
Cache-Control max-age=25920000, private
Expires Thu, 30 Dec 2010 09:39:47 GMT
Last-Modified Thu, 30 Dec 2010 00:15:14 GMT
Etag W/"124338-1293668114000"
Content-Type text/javascript
Content-Encoding gzip
Vary Accept-Encoding
Date Thu, 30 Dec 2010 09:29:42 GMT
(The "Expires" header set the expiry date in just 10 minutes, but it should be 1 month according to the Servlet filter codes)