Caching static PF resources problem
Caching static resources is a recommended way to make web pages load quickly. If I cache static Primefaces resources (both on users machines and on proxies), how can I upgrade to a new version of PF?
JSF implementation: Mojarra V2.1.7
JSF component library: Primefaces V3.1.1
Server: GlassFish Open Source Edition V3.1.1 (build 12)
JSF component library: Primefaces V3.1.1
Server: GlassFish Open Source Edition V3.1.1 (build 12)
MISS_DUKE,
The standard way to cache static resources like CSS or JS files is to label them with a version number like this
http://static.yourwebsite.com/css/style.css?v=1234
Assuming that you have set directives to cache the static resources in your .htaccess the browser will cache them. One way is to set expiry on them to say 60days or 30 days depending on your release schedule.
If you want to force invalidation of that cached resource and force browsers to download the new version, increment the version number as part of the next release deployment like this
http://static.yourwebsite.com/css/style.css?v=1235.
Browsers will see the change and request the new version. You can do the same with images. You can suffix the images with a version number like logo_<versionnumber>.png and keep incrementing that.
Hope this helps.
The standard way to cache static resources like CSS or JS files is to label them with a version number like this
http://static.yourwebsite.com/css/style.css?v=1234
Assuming that you have set directives to cache the static resources in your .htaccess the browser will cache them. One way is to set expiry on them to say 60days or 30 days depending on your release schedule.
If you want to force invalidation of that cached resource and force browsers to download the new version, increment the version number as part of the next release deployment like this
http://static.yourwebsite.com/css/style.css?v=1235.
Browsers will see the change and request the new version. You can do the same with images. You can suffix the images with a version number like logo_<versionnumber>.png and keep incrementing that.
Hope this helps.
Netbeans 7.2| GlassFish 3.2 | PostgreSQL 9.1| MongoDB | Primefaces 3.4.2
_______________________________________________________________
Subraya Mallya
http://tinyhabit.com |http://twitter.com/tinyhabit
_______________________________________________________________
Subraya Mallya
http://tinyhabit.com |http://twitter.com/tinyhabit
Adding version number to a static resource is really good idea.
But this idea cannot be implemented with Primefaces because Primefaces automatically creating static contents, for example:
The URL for "utilities.js" will be the same in all Primefaces versions.
But this idea cannot be implemented with Primefaces because Primefaces automatically creating static contents, for example:
Code: Select all
/faces/javax.faces.resource/yui/utilities/utilities.js?ln=primefaces
JSF implementation: Mojarra V2.1.7
JSF component library: Primefaces V3.1.1
Server: GlassFish Open Source Edition V3.1.1 (build 12)
JSF component library: Primefaces V3.1.1
Server: GlassFish Open Source Edition V3.1.1 (build 12)
-
- Prime
- Posts: 18616
- Joined: 05 Jan 2009, 00:21
- Location: Cybertron
- Contact:
Starting with 2.2.RC2, resource url has the version information like;
Code: Select all
<script type="text/javascript" src="/showcase/javax.faces.resource/yui/utilities/utilities.js.jsf?ln=primefaces&v=2.2.RC2"></script>
But JSF (Mojarra 2.0.3) resources are not given any version numbers, for example:
/faces/javax.faces.resource/jsf.js?ln=javax.faces
So, what happens when we upgrade to next Mojarra version (when it is released) ?
/faces/javax.faces.resource/jsf.js?ln=javax.faces
So, what happens when we upgrade to next Mojarra version (when it is released) ?
JSF implementation: Mojarra V2.1.7
JSF component library: Primefaces V3.1.1
Server: GlassFish Open Source Edition V3.1.1 (build 12)
JSF component library: Primefaces V3.1.1
Server: GlassFish Open Source Edition V3.1.1 (build 12)
Besides logging this issue with the Mojarra team, in the interim, you can add directives in .htaccess for the site to control this.
Expiry setting
<FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$">
Header set Expires "Thu, 31 Mar 2011 20:00:00 GMT"
</FilesMatch>
and Cache Control
# value in seconds
<FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$">
Header set Cache-Control "max-age=290304000, public"
</FilesMatch>
Expiry setting
<FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$">
Header set Expires "Thu, 31 Mar 2011 20:00:00 GMT"
</FilesMatch>
and Cache Control
# value in seconds
<FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$">
Header set Cache-Control "max-age=290304000, public"
</FilesMatch>
Netbeans 7.2| GlassFish 3.2 | PostgreSQL 9.1| MongoDB | Primefaces 3.4.2
_______________________________________________________________
Subraya Mallya
http://tinyhabit.com |http://twitter.com/tinyhabit
_______________________________________________________________
Subraya Mallya
http://tinyhabit.com |http://twitter.com/tinyhabit
Missed that - here is something I had in my archive http://blogs.sun.com/cwebster/entry/cac ... _glassfish although I have not tried it myself yet.
Netbeans 7.2| GlassFish 3.2 | PostgreSQL 9.1| MongoDB | Primefaces 3.4.2
_______________________________________________________________
Subraya Mallya
http://tinyhabit.com |http://twitter.com/tinyhabit
_______________________________________________________________
Subraya Mallya
http://tinyhabit.com |http://twitter.com/tinyhabit
-
- Information
-
Who is online
Users browsing this forum: No registered users and 38 guests