Class CacheFilter
java.lang.Object
com.levigo.jadice.web.server.filter.CacheFilter
- All Implemented Interfaces:
jakarta.servlet.Filter
@WebFilter(description="Enable caching for cacheable GWT resources",
displayName="jadice web toolkit GWT resource caching",
filterName="jwtCacheFilter",
urlPatterns="/*",
asyncSupported=true)
public class CacheFilter
extends Object
implements jakarta.servlet.Filter
This
Filter
adds the required HTTP Headers to the to the HttpServletResponse
to
allow the browser to cache the requested resource.
By default this filter is applied to GWT's *.cache.* files. If any of these resources is requested
the filter will inject the following HTTP headers into the response:
- Cache-Control: public, max-age=cacheExpirySeconds
- Expires: System.currentTimeMillis() + cacheExpirySeconds * 1000
- Pragma will be deleted, if existing
-
Field Summary
Modifier and TypeFieldDescriptionstatic final long
Default value used when initialization parameterPARAM_CACHE_EXPIRY_SECONDS
is not given.static final String
Name of initialization parameter. -
Constructor Summary
ConstructorDescriptionDefault constructor.CacheFilter
(String... additionalPatterns) Constructs a filter instance with additional patterns. -
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
Checks whether this filter applies to the given path.void
destroy()
void
doFilter
(jakarta.servlet.ServletRequest request, jakarta.servlet.ServletResponse response, jakarta.servlet.FilterChain chain) void
init
(jakarta.servlet.FilterConfig filterConfig)
-
Field Details
-
PARAM_CACHE_EXPIRY_SECONDS
Name of initialization parameter.- See Also:
-
CACHE_EXPIRY_SECONDS_DEFAULT
public static final long CACHE_EXPIRY_SECONDS_DEFAULTDefault value used when initialization parameterPARAM_CACHE_EXPIRY_SECONDS
is not given.- See Also:
-
-
Constructor Details
-
CacheFilter
public CacheFilter()Default constructor. -
CacheFilter
Constructs a filter instance with additional patterns.- Parameters:
additionalPatterns
- regular expressions
-
-
Method Details
-
init
public void init(jakarta.servlet.FilterConfig filterConfig) throws jakarta.servlet.ServletException - Specified by:
init
in interfacejakarta.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 interfacejakarta.servlet.Filter
- Throws:
IOException
jakarta.servlet.ServletException
-
appliesTo
Checks whether this filter applies to the given path.- Parameters:
path
- path of the requested resource- Returns:
true
if one of the patterns matches the given path
-
destroy
public void destroy()- Specified by:
destroy
in interfacejakarta.servlet.Filter
-