I am trying to cache the servlet response but somehow it is not working (Firebug is giving me 200 OK each time i refresh the page). This is the code I added in the servlet:
response.setContentType("application/javascript");
long now = System.currentTimeMillis();
response.setCharacterEncoding("UTF-8");
response.setDateHeader("Last-Modified", 0);
response.addHeader("Cache-Control", "max-age=5184000");
response.setDateHeader("Expires", now + 5184000 * 1000);
response.addHeader("Vary", "Host");
I've also tried with setHeader
and with Last-Modified
, now.
Nothing seems to work. Any ideas?
Thanks
This is how firebug shows me the response/request headers (when the resource should have been fetched from cache but isnt):
Response Headersview source
Cache-Control max-age=5184000
Connection Keep-Alive
Content-Type application/javascript;charset=UTF-8
Date Thu, 21 Mar 2013 09:53:48 GMT
Expires Sun, 31 Mar 2013 16:51:01 GMT
Keep-Alive timeout=15, max=99
Request Headersview source
Accept */*
Accept-Encoding gzip, deflate
Accept-Language en-US,en;q=0.5
Cache-Control max-age=0