Hi folks, So I''ve got this app built on prototype, with a bunch of extra JS classes to do what we want. Now the problem is, when I make a change to one of those JS files (or an upgrade to prototype itself), how do I ensure that the client browsers refresh their cache with the latest JS? Clearly I want the browse to cache the large JS files, but I also want that cache to expire at some point, or I want to be able to force a re-fetch of all the scripts/css referred to (the equivalent of a shift-reload). This must be a solved problem, but I didn''t see the solution anywhere... do I stick something in the http header of the JS file? Thanks for any assistance, Rahul _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
In it''s very simple form you can do this - For first time include the js file like this - <script src="scripts/prototype.js?v=1" type="text/javascript"></script> After updates include it like this - <script src="scripts/prototype.js?v=2" type="text/javascript"></script> Keep bumping up the version number. Now there are lots of better ways of doing this and creating automated versioning by checking the md5 of the file etc etc, but this should solve your problem. Thank you, Mandy. ________________________________ From: rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org on behalf of Rahul Bhargava Sent: Fri 3/31/2006 11:48 PM To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org Subject: [Rails-spinoffs] refreshing JS libraries on client? Hi folks, So I''ve got this app built on prototype, with a bunch of extra JS classes to do what we want. Now the problem is, when I make a change to one of those JS files (or an upgrade to prototype itself), how do I ensure that the client browsers refresh their cache with the latest JS? Clearly I want the browse to cache the large JS files, but I also want that cache to expire at some point, or I want to be able to force a re-fetch of all the scripts/css referred to (the equivalent of a shift-reload). This must be a solved problem, but I didn''t see the solution anywhere... do I stick something in the http header of the JS file? Thanks for any assistance, Rahul _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
<p align=\"left\"><b><font face=\"Arial\" size=\"2\">GFI MailSecurity''s HTML threat engine found HTML scripts in this email and has disabled them.</font></b></p>I have a global js function that handles this... always makes sure the parameter after the ? is new, therefore the file is always loaded new on the client... ...once you get your application to a stable "release" point though, maybe think about going back to the old way... because this could potentially fill up your users'' harddrives... // use these functions to include references to extrenal files that might change frequently // (main use is for testing... it''s annoying to have to delete IE''s temp files every time I make a change to a js or css file) function IncludeScript(externalFile, defer) { var deferStr = ""; if (defer) deferStr = ''defer="defer"''; document.write(''<Xcript type="text/javascript" src="''+externalFile+''?''+new Date() * 1+''" '' + deferStr + ''><!--<\/script>''); } ________________________________ From: rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org [mailto:rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org] On Behalf Of Maninder, Singh Sent: Friday, March 31, 2006 12:22 PM To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org Subject: RE: [Rails-spinoffs] refreshing JS libraries on client? In it''s very simple form you can do this - For first time include the js file like this - <script src="scripts/prototype.js?v=1" type="text/javascript">--></Xcript> After updates include it like this - <Xcript src="scripts/prototype.js?v=2" type="text/javascript"></Xcript> Keep bumping up the version number. Now there are lots of better ways of doing this and creating automated versioning by checking the md5 of the file etc etc, but this should solve your problem. Thank you, Mandy. ________________________________ From: rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org on behalf of Rahul Bhargava Sent: Fri 3/31/2006 11:48 PM To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org Subject: [Rails-spinoffs] refreshing JS libraries on client? Hi folks, So I''ve got this app built on prototype, with a bunch of extra JS classes to do what we want. Now the problem is, when I make a change to one of those JS files (or an upgrade to prototype itself), how do I ensure that the client browsers refresh their cache with the latest JS? Clearly I want the browse to cache the large JS files, but I also want that cache to expire at some point, or I want to be able to force a re-fetch of all the scripts/css referred to (the equivalent of a shift-reload). This must be a solved problem, but I didn''t see the solution anywhere... do I stick something in the http header of the JS file? Thanks for any assistance, Rahul The information transmitted in this electronic mail is intended only for the person or entity to which it is addressed and may contain confidential, proprietary, and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from all computers. _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
<p align=\"left\"><b><font face=\"Arial\" size=\"2\">GFI MailSecurity''s HTML threat engine found HTML scripts in this email and has disabled them.</font></b></p>Oops.. forgot to also include the on for stylesheets... function IncludeStyleSheet(externalFile) { document.write(''<link rel="stylesheet" type="text/css" href="''+externalFile+''?''+new Date() * 1+''"><\/script>''); } ________________________________ From: rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org [mailto:rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org] On Behalf Of Ryan Gahl Sent: Friday, March 31, 2006 1:45 PM To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org Subject: RE: [Rails-spinoffs] refreshing JS libraries on client? I have a global js function that handles this... always makes sure the parameter after the ? is new, therefore the file is always loaded new on the client... ...once you get your application to a stable "release" point though, maybe think about going back to the old way... because this could potentially fill up your users'' harddrives... // use these functions to include references to extrenal files that might change frequently // (main use is for testing... it''s annoying to have to delete IE''s temp files every time I make a change to a js or css file) function IncludeScript(externalFile, defer) { var deferStr = ""; if (defer) deferStr = ''defer="defer"''; document.write(''<Xcript type="text/javascript" src="''+externalFile+''?''+new Date() * 1+''" '' + deferStr + ''><!--<\/script>''); } ________________________________ From: rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org [mailto:rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org] On Behalf Of Maninder, Singh Sent: Friday, March 31, 2006 12:22 PM To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org Subject: RE: [Rails-spinoffs] refreshing JS libraries on client? In it''s very simple form you can do this - For first time include the js file like this - <script src="scripts/prototype.js?v=1" type="text/javascript">--></Xcript> After updates include it like this - <Xcript src="scripts/prototype.js?v=2" type="text/javascript"></Xcript> Keep bumping up the version number. Now there are lots of better ways of doing this and creating automated versioning by checking the md5 of the file etc etc, but this should solve your problem. Thank you, Mandy. ________________________________ From: rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org on behalf of Rahul Bhargava Sent: Fri 3/31/2006 11:48 PM To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org Subject: [Rails-spinoffs] refreshing JS libraries on client? Hi folks, So I''ve got this app built on prototype, with a bunch of extra JS classes to do what we want. Now the problem is, when I make a change to one of those JS files (or an upgrade to prototype itself), how do I ensure that the client browsers refresh their cache with the latest JS? Clearly I want the browse to cache the large JS files, but I also want that cache to expire at some point, or I want to be able to force a re-fetch of all the scripts/css referred to (the equivalent of a shift-reload). This must be a solved problem, but I didn''t see the solution anywhere... do I stick something in the http header of the JS file? Thanks for any assistance, Rahul The information transmitted in this electronic mail is intended only for the person or entity to which it is addressed and may contain confidential, proprietary, and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from all computers. _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs