Glassfish 3.1.2, Mojarra 2.1.6, SSL activated
I have an question about static resource caching. I´ve read some posts about this but I´m not sure which options we sho
You only need to set Cache-Control
. The Expires
and Last-Modified
are already set by default ResourceHandler (and would override the values set by your filter). The Last-Modified
must represent the last modified timestamp of the resource in question. You can obtain it by servletContext.getResource(path).openConnection().getLastModified()
. But you don't need to set it here anyway. Just let ResourceHandler
handle.
As to versioning, just use resource libraries rightly. You can put a version folder matching regex pattern \d+(_\d+)*
in the library folder and the ResourceHandler
will serve the newest.
E.g.
/resources/libraryname/1_0/js/file.js
/resources/libraryname/1_1/js/file.js
/resources/libraryname/1_2/js/file.js
The following will then get the one from 1_2
:
<h:outputScript library="libraryname" name="js/file.js" />