We want the web server to return the following http headers in all responses containing sensitive content:
Cache-control:no-store
Pragma:no-cache.
We are using tomcat server 6.0 version.
Please suggest where we have to make changes.
We want the web server to return the following http headers in all responses containing sensitive content:
Cache-control:no-store
Pragma:no-cache.
We are using tomcat server 6.0 version.
Please suggest where we have to make changes.
Servlet Filter like this should help:
public class ResourceCacheFilter implements Filter {
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
HttpServletResponse res = (HttpServletResponse) response;
res.setHeader("Cache-Control", "no-store, no-cache, must-revalidate, post-check=0, pre-check=0");
res.setHeader("Pragma", "no-cache");
chain.doFilter(request, response);
}
}
Depending on your security constraint you can setup tomcat valve to have securePagesWithPragma to true (default) which would set the headers as you requested. please refer to Tomcat6 Valve Documentation for further details and also Tomcat: Cache-Control