Add a javax.servlet.Filter , write the appropriate logic in the doFilter() method, and finally draw it in web.xml on the url-pattern from /* .
By the way, the set of "magic" that works in all known browsers and proxies is as follows:
response.setHeader("Cache-Control", "no-cache, no-store, must-revalidate"); // HTTP 1.1. response.setHeader("Pragma", "no-cache"); // HTTP 1.0. response.setDateHeader("Expires", 0); // Proxies.
source share