public class VersionedResourceHandler extends DefaultResourceHandler
v
to all resource URLs so that the browser
cache will be busted whenever the version parameter changes.
NOTE: if resource URL already has v
query string parameter, or when it is URL-rewritten to not include
"/javax.faces.resource"
path anymore, then these will be ignored.
To get it to run, this handler needs be registered as follows in faces-config.xml
:
<application>
<resource-handler>org.omnifaces.resourcehandler.VersionedResourceHandler</resource-handler>
</application>
And the version parameter needs to be configured as follows in web.xml
:
<context-param>
<param-name>org.omnifaces.VERSIONED_RESOURCE_HANDLER_VERSION</param-name>
<!-- Version parameter value could be any hardcoded string here, or any object property from managed bean -->
<param-value>#{environmentInfo.version}</param-value>
</context-param>
Modifier and Type | Field and Description |
---|---|
static String |
PARAM_NAME_VERSION
The context parameter name to specify value of the version to be appended to the resource URL.
|
RES_NOT_FOUND
JSF_SCRIPT_LIBRARY_NAME, JSF_SCRIPT_RESOURCE_NAME, LOCALE_PREFIX, RESOURCE_CONTRACT_XML, RESOURCE_EXCLUDES_DEFAULT_VALUE, RESOURCE_EXCLUDES_PARAM_NAME, RESOURCE_IDENTIFIER, WEBAPP_CONTRACTS_DIRECTORY_PARAM_NAME, WEBAPP_RESOURCES_DIRECTORY_PARAM_NAME
Constructor and Description |
---|
VersionedResourceHandler(ResourceHandler wrapped) |
Modifier and Type | Method and Description |
---|---|
Resource |
decorateResource(Resource resource)
Decorate the given resource.
|
createResource, createResource, createResource, createResourceFromLibrary, decorateResource, getLibraryName
createResourceFromId, createViewResource, getRendererTypeForResourceName, getViewResources, getViewResources, getWrapped, handleResourceRequest, isResourceRendered, isResourceRequest, isResourceURL, libraryExists, markResourceRendered
public static final String PARAM_NAME_VERSION
public VersionedResourceHandler(ResourceHandler wrapped)
public Resource decorateResource(Resource resource)
DefaultResourceHandler
The default implementation just returns the given resource unmodified.
decorateResource
in class DefaultResourceHandler
resource
- The resource to be decorated.Copyright © 2012–2025 OmniFaces. All rights reserved.