You can make use of JSF builtin resource library versioning. You'll only need to introduce a resource library in webapp's /resources
folder if not done yet. Then you can create a version subfolder with the pattern \d(_\d)*
. For example,
/resources/default/1_0/css/layout.css
Which you reference as follows:
<h:outputStylesheet library="default" name="css/layout.css" />
The library version is appended as v
parameter in the query string of the generated <link>
element.
<link type="text/css" rel="stylesheet" href="/contextname/javax.faces.resource/css/layout.js.xhtml?ln=default&v=1_0" />
When you need to deploy an update, rename the 1_0
subfolder to 1_1
or something different (can be done by ant) and it'll be updated and the browser will be forced to download it instead of using the cached one.
The same applies to <h:outputScript>
and <h:graphicImage>
for JS and image resources.