how to disable web page cache throughout the servlets
Posted
by
Kurt
on Stack Overflow
See other posts from Stack Overflow
or by Kurt
Published on 2014-05-29T21:24:35Z
Indexed on
2014/05/30
9:26 UTC
Read the original article
Hit count: 312
To no-cache web page, in the java controller servlet, I did somthing like this in a method:
public ModelAndView home(HttpServletRequest request, HttpServletResponse response) throws Exception {
ModelAndView mav = new ModelAndView(ViewConstants.MV_MAIN_HOME);
mav.addObject("testing", "Test this string");
mav.addObject(request);
response.setHeader("Cache-Control", "no-cache, no-store");
response.setHeader("Pragma", "no-cache");
response.setDateHeader("Expires", 0);
return mav;
}
But this only works for a particular response object. I have many similar methods in a servlet. And I have many servlets too.
If I want to disable cache throughout the application, what should I do? (I do not want to add above code for every single response object)
Thanks in advance.
© Stack Overflow or respective owner