Class NoCacheFilter

  • All Implemented Interfaces:
    javax.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 javax.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 Detail

      • NoCacheFilter

        public NoCacheFilter()
      • NoCacheFilter

        public NoCacheFilter​(String... additionalPatterns)
    • Method Detail

      • init

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

        public void doFilter​(javax.servlet.ServletRequest request,
                             javax.servlet.ServletResponse response,
                             javax.servlet.FilterChain chain)
                      throws IOException,
                             javax.servlet.ServletException
        Specified by:
        doFilter in interface javax.servlet.Filter
        Throws:
        IOException
        javax.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 javax.servlet.Filter