commit d653721d9320a8e3158f82e5b875692f93443f27
Author: Brandon Turner <brandont@thinkwell.com>
Date:   Tue Jul 20 10:11:18 2010

    Added support for JS caching and revisions via yui_combo.php
    
    Moodle modules loaded via yui_module now contain a revision number in the URL
    used to load them.  Also the cachejs configuration option applies to Moodle
    modules loaded via yui_module as well - turning this option off will cause
    Moodle modules to not be cached.
    
    Regular YUI modules and YUI Gallery modules are unaffected as they have built
    in versions.

diff --git a/lib/outputrequirementslib.php b/lib/outputrequirementslib.php
index 58c7a58..1a4e87e 100644
--- a/lib/outputrequirementslib.php
+++ b/lib/outputrequirementslib.php
@@ -153,8 +153,8 @@ class page_requirements_manager {
         $this->M_yui_loader->groups       = array(
             'moodle' => array(
                 'name' => 'moodle',
-                'base' => $CFG->httpswwwroot . '/theme/yui_combo.php?moodle/',
-                'comboBase' => $CFG->httpswwwroot . '/theme/yui_combo.php?',
+                'base' => $CFG->httpswwwroot . '/theme/yui_combo.php?' . (empty($CFG->cachejs)?'nocache&':'') . (empty($CFG->jsrev)?'':'rev='.$CFG->jsrev.'&') . 'moodle/',
+                'comboBase' => $CFG->httpswwwroot . '/theme/yui_combo.php?' . (empty($CFG->cachejs)?'nocache&':'') . (empty($CFG->jsrev)?'':'rev='.$CFG->jsrev.'&'),
                 'combine' => $this->yui3loader->combine,
                 'filter' => '',
                 'ext' => false,
diff --git a/theme/yui_combo.php b/theme/yui_combo.php
index 53be0d7..ec7f58e 100644
--- a/theme/yui_combo.php
+++ b/theme/yui_combo.php
@@ -46,11 +46,19 @@ if (substr($parts, -3) === '.js') {
 }
 
 $parts = explode('&', $parts);
+$sendCached = true;
 
 foreach ($parts as $part) {
     if (empty($part)) {
         continue;
     }
+    if (strpos($part, 'rev')!==false) {
+        continue;
+    }
+    if (strpos($part, 'nocache')!==false) {
+        $sendCached = false;
+        continue;
+    }
     $part = min_clean_param($part, 'SAFEPATH');
     $bits = explode('/', $part);
     if (count($bits) < 2) {
@@ -99,7 +107,11 @@ foreach ($parts as $part) {
 }
 
 
-combo_send_cached($content, $mimetype);
+if($sendCached) {
+    combo_send_cached($content, $mimetype);
+} else {
+    combo_send_uncached($content, $mimetype);
+}
 
 
 
@@ -121,6 +133,19 @@ function combo_send_cached($content, $mimetype) {
     die;
 }
 
+function combo_send_uncached($content, $mimetype) {
+    header('Content-Disposition: inline; filename="combo"');
+    header('Last-Modified: '. gmdate('D, d M Y H:i:s', time()) .' GMT');
+    header('Accept-Ranges: none');
+    header('Content-Type: '.$mimetype);
+    if (!min_enable_zlib_compression()) {
+        header('Content-Length: '.strlen($content));
+    }
+
+    echo $content;
+    die;
+}
+
 function combo_not_found() {
     header('HTTP/1.0 404 not found');
     die('Combo resource not found, sorry.');
