Package org.jivesoftware.admin
Class CacheControlFilter
java.lang.Object
org.jivesoftware.admin.CacheControlFilter
- All Implemented Interfaces:
javax.servlet.Filter
A servlet filter that sets HTTP Cache-Control headers for the Openfire Admin Console.
This filter distinguishes between static resources and dynamic administrative content:
- Static assets (images, scripts, stylesheets, fonts) receive configurable short-term caching headers to reduce redundant requests and improve responsiveness.
- Dynamic and administrative pages receive no-store/no-cache headers to prevent sensitive content from being cached by browsers or proxies.
Headers are applied after the filter chain has executed, and only when the response
status indicates success (200 or 304). This prevents error responses from accidentally
receiving cache headers. If a Cache-Control header has already been set by another
servlet or filter, this filter will not overwrite it.
Both the set of static resource file extensions and the cache duration are configurable via Openfire system properties.
- Author:
- Milan Tyagi
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final SystemProperty<List<String>>A list of file extensions that are considered static resources.static final SystemProperty<Duration>The maximum duration that static resources may be cached by browsers and proxies. -
Constructor Summary
Constructors -
Method Summary
-
Field Details
-
STATIC_RESOURCE_EXTENSIONS
A list of file extensions that are considered static resources. Requests for resources matching these extensions will receive short-term caching headers. -
STATIC_RESOURCE_MAX_AGE
The maximum duration that static resources may be cached by browsers and proxies. The default value is one hour (PT1H).
-
-
Constructor Details
-
CacheControlFilter
public CacheControlFilter()
-
-
Method Details
-
init
public void init(javax.servlet.FilterConfig filterConfig) throws javax.servlet.ServletException - Specified by:
initin interfacejavax.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:
doFilterin interfacejavax.servlet.Filter- Throws:
IOExceptionjavax.servlet.ServletException
-
destroy
public void destroy()- Specified by:
destroyin interfacejavax.servlet.Filter
-