I would like my Spring Controller to cache the content which returns. I have found a lot of questions how to disable caching. I would like to know how to enable caching. My Controller looks like this one:
@Controller
public class SimpleController {
@RequestMapping("/webpage.htm")
public ModelAndView webpage(HttpServletRequest request,
HttpServletResponse response) {
ModelAndView mav = new ModelAndView("webpage");
httpServletResponse.setHeader(“Cache-Control”, “public”);
//some code
return mav;
}
}
As you can see I have added the line: httpServletResponse.setHeader(“Cache-Control”, “public”);
to set caching but in my browser when I refresh this page I am still getting the same status result: 200 OK
. How can I achieve result 304 not modified
? I can set annotation @ResponseStatus(value = HttpStatus.NOT_MODIFIED)
on this method but will it be only status or also actual caching?