All javascript and css requests now append the version number to the URL to break browser caches and prevent from having to clear the cache upon upgrade
authorDan
Sun, 27 Dec 2009 02:28:21 -0500
changeset 1196 704ba4b9819b
parent 1195 449fdd113eb0
child 1197 3a0a7a4743d2
All javascript and css requests now append the version number to the URL to break browser caches and prevent from having to clear the cache upon upgrade
includes/clientside/static/enano-lib-basic.js
includes/clientside/static/l10n.js
includes/template.php
themes/admin/header.tpl
themes/enanium/header.tpl
themes/oxygen/header.tpl
themes/stpatty/header.tpl
--- a/includes/clientside/static/enano-lib-basic.js	Sun Dec 27 02:27:35 2009 -0500
+++ b/includes/clientside/static/enano-lib-basic.js	Sun Dec 27 02:28:21 2009 -0500
@@ -294,7 +294,7 @@
   
   if ( !multiple )
     file = file + '.js';
-  var uri = ( ENANO_JSRES_COMPRESSED ) ? scriptPath + '/includes/clientside/jsres.php?f=' + (multiple ? file_flat : file ) : scriptPath + '/includes/clientside/static/' + file;
+  var uri = ( ENANO_JSRES_COMPRESSED ) ? scriptPath + '/includes/clientside/jsres.php?f=' + (multiple ? file_flat : file ) + '&' + enano_version : scriptPath + '/includes/clientside/static/' + file + '?' + enano_version;
   try
   {
     ajax.open('GET', uri, false);
--- a/includes/clientside/static/l10n.js	Sun Dec 27 02:27:35 2009 -0500
+++ b/includes/clientside/static/l10n.js	Sun Dec 27 02:28:21 2009 -0500
@@ -19,7 +19,7 @@
     load_show_win('strings');
     console.info('Loading language ' + lang_id + ' via AJAX synchronous request');
     var ajax = ajaxMakeXHR();
-    var uri = makeUrlNS('Special', 'LangExportJSON/' + lang_id);
+    var uri = makeUrlNS('Special', 'LangExportJSON/' + lang_id, enano_version);
     ajax.open('GET', uri, false);
     ajax.send(null);
     if ( ajax.readyState == 4 && ajax.status == 200 )
--- a/includes/template.php	Sun Dec 27 02:27:35 2009 -0500
+++ b/includes/template.php	Sun Dec 27 02:28:21 2009 -0500
@@ -514,13 +514,16 @@
       $ash = '';
     }
     
+    // Append the Enano version to URLs to break the cache on upgrades
+    $enano_version = enano_version();
+    
     // Set up javascript includes
     // these depend heavily on whether we have a CDN to work with or not
     if ( getConfig('cdn_path') )
     {
       // we're on a CDN, point to static includes
       // CLI javascript compression script: includes/clientside/jscompress.php
-      $js_head = '<script type="text/javascript" src="' . cdnPath . '/includes/clientside/static/enano-lib-basic.js"></script>';
+      $js_head = '<script type="text/javascript" src="' . cdnPath . '/includes/clientside/static/enano-lib-basic.js?' . $enano_version . '"></script>';
       
       if ( !empty($this->js_preload) )
       {
@@ -536,12 +539,12 @@
         
         foreach ( $this->js_preload as $script )
         {
-          $js_head .= "\n    <script type=\"text/javascript\" src=\"" . cdnPath . "/includes/clientside/static/$script\"></script>";
+          $js_head .= "\n    <script type=\"text/javascript\" src=\"" . cdnPath . "/includes/clientside/static/$script?$enano_version\"></script>";
           // special case for l10n: also load strings
           if ( $script == 'l10n.js' )
           {
             global $lang;
-            $js_head .= "\n    <script type=\"text/javascript\" src=\"" . makeUrlNS("Special", "LangExportJSON/$lang->lang_id") . "\"></script>";
+            $js_head .= "\n    <script type=\"text/javascript\" src=\"" . makeUrlNS("Special", "LangExportJSON/$lang->lang_id", "$enano_version") . "\"></script>";
           }
           $loadlines[] = "loaded_components['$script'] = true;";
         }
@@ -578,7 +581,7 @@
       // point to jsres compressor
       $js_head .= <<<JSEOF
       <!-- Only load a basic set of functions for now. Let the rest of the API load when the page is finished. -->
-      <script type="text/javascript" src="$cdnpath/includes/clientside/jsres.php?early"></script>
+      <script type="text/javascript" src="$cdnpath/includes/clientside/jsres.php?early&$enano_version"></script>
 JSEOF;
       $js_foot = '';
       
@@ -593,16 +596,16 @@
         {
           // special case for l10n: also load strings
           global $lang;
-          $js_foot .= "\n    <script type=\"text/javascript\" src=\"" . makeUrlNS("Special", "LangExportJSON/$lang->lang_id") . "\"></script>";
+          $js_foot .= "\n    <script type=\"text/javascript\" src=\"" . makeUrlNS("Special", "LangExportJSON/$lang->lang_id", $enano_version) . "\"></script>";
         }
         $scripts = implode(',', $this->js_preload);
-        $js_foot .= "\n    <script type=\"text/javascript\" src=\"" . cdnPath . "/includes/clientside/jsres.php?f=$scripts\"></script>";
+        $js_foot .= "\n    <script type=\"text/javascript\" src=\"" . cdnPath . "/includes/clientside/jsres.php?f=$scripts&$enano_version\"></script>";
         
       }
       
       $js_foot .= <<<JSEOF
     <!-- jsres.php is a wrapper script that compresses and caches single JS files to minimize requests -->
-    <script type="text/javascript" src="$cdnpath/includes/clientside/jsres.php"></script>
+    <script type="text/javascript" src="$cdnpath/includes/clientside/jsres.php?$enano_version"></script>
     <script type="text/javascript">//<![CDATA[
       // This initializes the Javascript runtime when the DOM is ready - not when the page is
       // done loading, because enano-lib-basic still has to load some 15 other script files
@@ -655,6 +658,7 @@
         'JS_HEADER' => $js_head,
         'JS_FOOTER' => $js_foot,
         'URL_ABOUT_ENANO' => makeUrlNS('Special', 'About_Enano', '', true),
+        'ENANO_VERSION' => enano_version()
       ), true);
     
     $tpl_strings = array();
@@ -1247,7 +1251,8 @@
       var AES_BLOCKSIZE = '.AES_BLOCKSIZE.';
       var pagepass = \''. ( ( isset($_REQUEST['pagepass']) ) ? sha1($_REQUEST['pagepass']) : '' ) .'\';
       var ENANO_LANG_ID = ' . $lang->lang_id . ';
-      var ENANO_PAGE_TYPE = "' . addslashes($this->namespace_string) . '";';
+      var ENANO_PAGE_TYPE = "' . addslashes($this->namespace_string) . '";
+      var enano_version = "' . enano_version() . '";';
     
     foreach ( $paths->nslist as $k => $c )
     {
--- a/themes/admin/header.tpl	Sun Dec 27 02:27:35 2009 -0500
+++ b/themes/admin/header.tpl	Sun Dec 27 02:28:21 2009 -0500
@@ -3,8 +3,8 @@
   <head>
     <title>{PAGE_NAME} &bull; {SITE_NAME}</title>
     <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
-    <link rel="stylesheet" type="text/css" href="{CDNPATH}/includes/clientside/css/enano-shared.css" />
-    <link id="mdgCss" rel="stylesheet" type="text/css" href="{CDNPATH}/themes/{THEME_ID}/css/{STYLE_ID}.css" />
+    <link rel="stylesheet" type="text/css" href="{CDNPATH}/includes/clientside/css/enano-shared.css?{ENANO_VERSION}" />
+    <link id="mdgCss" rel="stylesheet" type="text/css" href="{CDNPATH}/themes/{THEME_ID}/css/{STYLE_ID}.css?{ENANO_VERSION}" />
     <!--[if IE]>
     <link id="mdgCss" rel="stylesheet" type="text/css" href="{CDNPATH}/themes/{THEME_ID}/css-ie/iefixes.css" />
     <![endif]-->
--- a/themes/enanium/header.tpl	Sun Dec 27 02:27:35 2009 -0500
+++ b/themes/enanium/header.tpl	Sun Dec 27 02:28:21 2009 -0500
@@ -4,8 +4,8 @@
     <title>{PAGE_NAME} &bull; {SITE_NAME}</title>
     <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
     {JS_DYNAMIC_VARS}
-    <link rel="stylesheet" type="text/css" href="{CDNPATH}/includes/clientside/css/enano-shared.css" />
-    <link id="mdgCss" rel="stylesheet" type="text/css" href="{CDNPATH}/themes/{THEME_ID}/css/{STYLE_ID}.css" />
+    <link rel="stylesheet" type="text/css" href="{CDNPATH}/includes/clientside/css/enano-shared.css?{ENANO_VERSION}" />
+    <link id="mdgCss" rel="stylesheet" type="text/css" href="{CDNPATH}/themes/{THEME_ID}/css/{STYLE_ID}.css?{ENANO_VERSION}" />
     <!--[if lte IE 6]>
     <link rel="stylesheet" type="text/css" href="{CDNPATH}/themes/{THEME_ID}/css-extra/ie6.css" />
     <![endif]-->
--- a/themes/oxygen/header.tpl	Sun Dec 27 02:27:35 2009 -0500
+++ b/themes/oxygen/header.tpl	Sun Dec 27 02:28:21 2009 -0500
@@ -3,11 +3,11 @@
   <head>
     <title>{PAGE_NAME} &bull; {SITE_NAME}</title>
     <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
-    <link rel="stylesheet" type="text/css" href="{CDNPATH}/includes/clientside/css/enano-shared.css" />
+    <link rel="stylesheet" type="text/css" href="{CDNPATH}/includes/clientside/css/enano-shared.css?{ENANO_VERSION}" />
     <!-- BEGIN msie -->
-    <link rel="stylesheet" type="text/css" href="{CDNPATH}/includes/clientside/css/enano-shared.css" />
+    <link rel="stylesheet" type="text/css" href="{CDNPATH}/includes/clientside/css/enano-shared-ie.css?{ENANO_VERSION}" />
     <!-- END msie -->
-    <link id="mdgCss" rel="stylesheet" href="{CDNPATH}/themes/{THEME_ID}/css/{STYLE_ID}.css" type="text/css" />
+    <link id="mdgCss" rel="stylesheet" href="{CDNPATH}/themes/{THEME_ID}/css/{STYLE_ID}.css?{ENANO_VERSION}" type="text/css" />
     {JS_DYNAMIC_VARS}
     {JS_HEADER}
     
--- a/themes/stpatty/header.tpl	Sun Dec 27 02:27:35 2009 -0500
+++ b/themes/stpatty/header.tpl	Sun Dec 27 02:28:21 2009 -0500
@@ -4,9 +4,9 @@
     <title>{PAGE_NAME} &bull; {SITE_NAME}</title>
     <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
     {JS_DYNAMIC_VARS}
-    <link rel="stylesheet" type="text/css" href="{CDNPATH}/includes/clientside/css/enano-shared.css" />
-    <link rel="stylesheet" type="text/css" href="{CDNPATH}/themes/{THEME_ID}/css-extra/structure.css" />
-    <link id="mdgCss" rel="stylesheet" type="text/css" href="{CDNPATH}/themes/{THEME_ID}/css/{STYLE_ID}.css" />
+    <link rel="stylesheet" type="text/css" href="{CDNPATH}/includes/clientside/css/enano-shared.css?{ENANO_VERSION}" />
+    <link rel="stylesheet" type="text/css" href="{CDNPATH}/themes/{THEME_ID}/css-extra/structure.css?{ENANO_VERSION}" />
+    <link id="mdgCss" rel="stylesheet" type="text/css" href="{CDNPATH}/themes/{THEME_ID}/css/{STYLE_ID}.css?{ENANO_VERSION}" />
     {JS_HEADER}
     <!--[if lt IE 7]>
     <link rel="stylesheet" type="text/css" href="{CDNPATH}/themes/{THEME_ID}/css-extra/ie-fixes-{STYLE_ID}.css" />