Class TileCacheFilter

java.lang.Object
com.levigo.jadice.web.server.filter.TileCacheFilter
All Implemented Interfaces:
jakarta.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 jakarta.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 Details

    • PATTERN

      public static final Pattern PATTERN
  • Constructor Details

    • TileCacheFilter

      public TileCacheFilter()
    • TileCacheFilter

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