Class TileCacheFilter

  • All Implemented Interfaces:
    javax.servlet.Filter

    @WebFilter(description="Enable caching for jadice web toolkit tiles",
               displayName="jadice web toolkit tile caching",
               filterName="jwtTileCacheFilter",
               urlPatterns="/*",
               asyncSupported=true)
    public class TileCacheFilter
    extends Object
    implements javax.servlet.Filter
    This Filter adds the required HTTP Headers to the to the HttpServletResponse of the tiles to force the browser to cache the image resource that was returned and to configure the duration how long the cache entry is valid.

    The maximum age is configured to 30 minutes.

    This filter injects the following HTML headers into the response:

    • Cache-Control: private, max-age=60 * 30
    • Expires: 60 * 30 * 1000
    • Pragma will be deleted, if existing
    • Field Detail

      • PATTERN

        public static final Pattern PATTERN
    • Constructor Detail

      • TileCacheFilter

        public TileCacheFilter()
      • TileCacheFilter

        public TileCacheFilter​(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