-
Automatically adds version parameter with query string name
v
to all resource URLs so, in production mode they will be cached forever (or as configured in web.xml), but will not be stale when a new version of the app is deployed.
NOTE: if resource URL already has v
query string parameter, or when it is URL-rewritten to not include "/jakarta.faces.resource"
path anymore, then these will be ignored.
Example:
faces-config.xml:
<application>
<resource-handler>org.omnifaces.resourcehandler.VersionedResourceHandler</resource-handler>
</application>
web.xml:
<context-param>
<!-- Mojarra: 1 year cache, effects production mode only -->
<param-name>com.sun.faces.defaultResourceMaxAge</param-name>
<param-value>31536000000</param-value>
</context-param>
<context-param>
<param-name>org.omnifaces.VERSIONED_RESOURCE_HANDLER_VERSION</param-name>
<!-- Version string could be any string here, or taken from @Named bean -->
<param-value>#{environmentInfo.version}</param-value>
</context-param>
Documentation & Sources