Class NoCacheFilter

java.lang.Object
com.levigo.jadice.web.server.filter.NoCacheFilter
All Implemented Interfaces:
jakarta.servlet.Filter

@WebFilter(description="Disable caching for non-cacheable GWT resources", displayName="jadice web toolkit GWT resource non-caching", filterName="jwtNoCacheFilter", urlPatterns="/*", asyncSupported=true) public class NoCacheFilter extends Object implements jakarta.servlet.Filter
This Filter adds the required HTTP Headers to the HttpServletResponse to force the browser not to cache the resource that was returned.

Caching will be turned for all *.nocache.* files, by (GWT) design. Additionally, this filter excludes index.* from caching.

This filter injects the following HTML headers into the response:

  • Cache-Control: "no-cache, no-store, must-revalidate"
  • Expires: -1
  • Pragma: No-cache
  • Constructor Details

    • NoCacheFilter

      public NoCacheFilter()
    • NoCacheFilter

      public NoCacheFilter(String... additionalPatterns)
  • Method Details

    • init

      public void init(jakarta.servlet.FilterConfig filterConfig) throws jakarta.servlet.ServletException
      Specified by:
      init in interface jakarta.servlet.Filter
      Throws:
      jakarta.servlet.ServletException
    • doFilter

      public void doFilter(jakarta.servlet.ServletRequest request, jakarta.servlet.ServletResponse response, jakarta.servlet.FilterChain chain) throws IOException, jakarta.servlet.ServletException
      Specified by:
      doFilter in interface jakarta.servlet.Filter
      Throws:
      IOException
      jakarta.servlet.ServletException
    • appliesTo

      protected boolean appliesTo(String path)
      Checks whether this filter applies to the given path.
      Parameters:
      path - The path of the request
      Returns:
      true if one of the patterns matches the given path and the headers shall be applied
    • destroy

      public void destroy()
      Specified by:
      destroy in interface jakarta.servlet.Filter