Not signed in (Sign In)
 
Aug 18th 2008
 
We could append vanilla version number to the css and js files, so that each time vanilla is upgraded js and css files will be reloaded; for the browser, example.com/js/ac.js and example.com/js/ac.js?v=1.1.4 are different resources with their own cache.
 
Aug 18th 2008 edited
 
Here is the patch for vanilla:

Index: src/appg/init_people.php
===================================================================
--- src/appg/init_people.php (revision 729)
+++ src/appg/init_people.php (working copy)
@@ -66,8 +66,8 @@

// BUILD THE PAGE HEAD
// Every page will require some basic definitions for the header.
-$Head->AddScript('js/global.js');
-$Head->AddStyleSheet($Context->StyleUrl.'people.css', 'screen', 100, '');
+$Head->AddScript('js/global.js?v='.APPLICATION_VERSION);
+$Head->AddStyleSheet($Context->StyleUrl.'people.css?v='.APPLICATION_VERSION, 'screen', 100, '');

// INCLUDE EXTENSIONS
if ($Configuration['PEOPLE_USE_EXTENSIONS']) {
Index: src/appg/init_vanilla.php
===================================================================
--- src/appg/init_vanilla.php (revision 729)
+++ src/appg/init_vanilla.php (working copy)
@@ -75,12 +75,12 @@

// BUILD THE PAGE HEAD
// Every page will require some basic definitions for the header.
-$Head->AddScript('js/global.js');
-$Head->AddScript('js/vanilla.js');
-$Head->AddScript('js/ajax.js');
-$Head->AddScript('js/ac.js');
-$Head->AddStyleSheet($Context->StyleUrl.'vanilla.css', 'screen', 100, '');
-$Head->AddStyleSheet($Context->StyleUrl.'vanilla.print.css', 'print', 101, '');
+$Head->AddScript('js/global.js?v='.APPLICATION_VERSION);
+$Head->AddScript('js/vanilla.js?v='.APPLICATION_VERSION);
+$Head->AddScript('js/ajax.js?v='.APPLICATION_VERSION);
+$Head->AddScript('js/ac.js?v='.APPLICATION_VERSION);
+$Head->AddStyleSheet($Context->StyleUrl.'vanilla.css?v='.APPLICATION_VERSION, 'screen', 100, '');
+$Head->AddStyleSheet($Context->StyleUrl.'vanilla.print.css?v='.APPLICATION_VERSION, 'print', 101, '');

// BUILD THE MAIN MENU
$Menu->AddTab($Context->GetDefinition('Discussions'), 'discussions',
GetUrl($Configuration, './'), '', $Configuration['TAB_POSITION_DISCUSSIONS']);
Index: src/library/Vanilla/Vanilla.Control.CategoryForm.php
===================================================================
--- src/library/Vanilla/Vanilla.Control.CategoryForm.php (revision 729)
+++ src/library/Vanilla/Vanilla.Control.CategoryForm.php (working copy)
@@ -41,8 +41,8 @@
// Add the javascript to the head for sorting categories
if ($this->PostBackAction == "Categories") {
global $Head;
- $Head->AddScript('js/prototype.js');
- $Head->AddScript('js/scriptaculous.js');
+ $Head->AddScript('js/prototype.js?v='.APPLICATION_VERSION);
+ $Head->AddScript('js/scriptaculous.js?v='.APPLICATION_VERSION);
}

$CategoryID = ForceIncomingInt('CategoryID', 0);
 
Aug 18th 2008
 
... and for People:

Index: People.Control.RoleForm.php
===================================================================
--- People.Control.RoleForm.php (revision 105)
+++ People.Control.RoleForm.php (working copy)
@@ -43,8 +43,8 @@
// Add the javascript to the head for sorting roles
if ($this->PostBackAction == "Roles") {
global $Head;
- $Head->AddScript('js/prototype.js');
- $Head->AddScript('js/scriptaculous.js');
+ $Head->AddScript('js/prototype.js?v='.APPLICATION_VERSION);
+ $Head->AddScript('js/scriptaculous.js?v='.APPLICATION_VERSION);
}

$RoleID = ForceIncomingInt('RoleID', 0);
 
Aug 18th 2008 edited
 
An alternative solution would be to let Head::AddScript() and Head::AddStyleSheet() append the version number.
 
Aug 19th 2008
 
added the first solution to Vanilla r732 and People r106
 
Aug 21st 2008
 
I'm not so sure about this change... I know rails and I think wordpress do something similar, but I've heard it breaks caching on some browsers--meaning the files get reloaded with every page load.

I'll have to test it out.
 
Aug 22nd 2008 edited
 
Tested it on:
- FF 3.0.1 (Vista)
- Opera 9.23 (Vista)
- Opera 9.52 (Vista)
- IE 7.0.6001.18000 (Vista)
- Safari 3.1.2 (Vista)
- Firefox 2.0.14 (XP sp2)
- IE6.0.2900.2180 (XP sp2)

for the test, I hard refresh the page then look the request generated for the following visits using a proxy (Fiddler 2).
 
Aug 22nd 2008 edited
 
According to the http specification, resources with query string shouldn't be cached:
http://www.w3.org/Protocols/rfc2616/rfc2616-sec13.html#sec13.9

Alternative solutions require mod_rewrite:
RewriteRule ^/(.*\.)v[0-9.]+\.(css|js|gif|png|jpg)$ /$1$2 [L]
(http://www.thinkvitamin.com/features/webapps/serving-javascript-fast)

We have to leave that for an extension.
 
Aug 22nd 2008 edited
 
Reverted changes. People r107, Vanilla r737.

Issue information

  • 77
  • Dinoboff

    Dinoboff

    Bug Tracker

  • Resolved
  • Low
  • Feature

Vanilla 1.1.5 is a product of Lussumo. More Information: Documentation, Community Support.