3

The JS file extra.js is included as follows:

<h:outputScript library="js" name="extra.js"  />

I am facing issue of browser caching. Many times, I will not get the updated copy.

In plain HTML, we used to append version number or random number with JS URL like:

<script type="text/javascript" src="http://yyy.zzzz.net/js/tryjs?v=1234"></script>
where v is the version number.

Is there any way to add some version number to the generated resource URL in h:outputScript?

BalusC
  • 1,040,783
  • 362
  • 3,548
  • 3,513
Shashi
  • 11,950
  • 17
  • 62
  • 109
  • possible duplicate of [JSF resource versioning](http://stackoverflow.com/questions/9929417/jsf-resource-versioning) – BalusC May 29 '13 at 13:46

1 Answers1

5

You can do one of the following

Manage the version number in one of you beans #{myBean.myVersion} and append it to you js file in h:outputScript

Like this:

<h:outputScript library="js" name="extra.js?#{myBean.myVersion}/>

or rename your js file to include the #{myBean.myVersion} as a part of its name like this

<h:outputScript library="js" name="extra.#{myBean.myVersion}.js/>

Also you can take a look at this : Resources (Library) In JSF 2.0

Daniel
  • 36,273
  • 9
  • 115
  • 187