Используйте фильтр, настройте свой фильтр в web.xml
<filter>
<filter-name>cacheControlFilter</filter-name>
<filter-class>com.package.CacheControlFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>cacheControlFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
И ваш класс фильтра
import javax.servlet.*;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Date;
public class CacheControlFilter implements Filter {
public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain) throws IOException, ServletException {
HttpServletResponse resp = (HttpServletResponse) response;
resp.setHeader("Expires", "Tue, 25 Dec 1993 23:59:59 GMT");
resp.setHeader("Last-Modified", new Date().toString());
resp.setHeader("Cache-Control", "no-cache");
resp.setHeader("Pragma", "no-cache");
chain.doFilter(request, response);
}
}