Java EE doesn't define a dedicated API (or specification) for HTTP caching, but it provides a few helpers.
The more direct (and low level) way to configure it is by using the Servlet specification, which abstracts the HTTP layer:
public class NoStoreFilter implements Filter { @Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain filterChain) throws IOException, ServletException { final HttpServletResponse httpResponse = HttpServletResponse.class.cast(response); httpResponse.setHeader("Cache-Control", "no-store"); filterChain.doFilter(request, response); }}
With this filter, the Cache-Control value will prevent the cached data from being persistently stored. To activate ...