1

When you have multiple resources (js, css, images) it's a great performance boost to set the caching policy in production environment, so that the browser won't ask each time if new version of resource is available.

The issue is, when you update the application, the browser still uses (for some time) the old resources. While with css and images it's an inconvinience, when it's JavaScript, the application will mostly not function.

The solution is well known. Either rename the resources (not practical) or apppend version param to request (such as &ver=XYZ).

My question is, how to do the second in JSF 2? So, do not change library name or create new folder for new version in resources. I want to have the request parameter appended to request, preserving resource path.

How to append such param to resources included via h:outputScript and h:outputStylesheet tags in xhtml, and via @ResourceDependency annotation in custom components?

At best, if it could be specified globally in application, and affecting all generated resource links.

Danubian Sailor
  • 1
  • 38
  • 145
  • 223
  • 1
    Use the library attribute, read this: http://stackoverflow.com/questions/9868068/how-to-specify-resource-library-version-in-jsf2 – Christophe Roussy Feb 22 '13 at 09:03
  • You mean 'version' attribute? But it is not available on @ResourceDependency. – Danubian Sailor Feb 22 '13 at 10:02
  • I mean the attribute on the `h:outputScript` – Christophe Roussy Feb 22 '13 at 10:18
  • But the version is not available on @ResourceDependency, so it doesn't address the issue... and the version attribute is AFAIK working so, that I must rename the folder in resources after changing it, which is practically the first solution, when I want the second. I've updated the question. – Danubian Sailor Feb 22 '13 at 10:22
  • 1
    Why not use the standard resource mechanism ? When you update a library you do changes on the filesystem anyways. – Christophe Roussy Feb 22 '13 at 10:30
  • I do not understand what do you mean by standard? The filesystem changes but browser makes no new request becasue the resource with that name is already in cache, so the name must change, if the browser cache is to be used. – Danubian Sailor Feb 22 '13 at 11:30
  • But it's always required to rename the folder? I'd like to be able to mark the version as changed without changing the folder name. And the reason behing, PrimeFaces are making no versioning and swiching to new version would unleash chaos ... – Danubian Sailor Feb 22 '13 at 12:26
  • It looks like that: javax.faces.resource/jquery/jquery.js.xhtml?ln=primefaces, no versioning (PrimeFaces 3.4) – Danubian Sailor Feb 22 '13 at 12:56

0 Answers0