Cache by default raw views for CSS & JS files for all users, controllable by $wgForce...
authorDomas Mituzas <midom@users.mediawiki.org>
Tue, 13 Nov 2007 13:24:51 +0000 (13:24 +0000)
committerDomas Mituzas <midom@users.mediawiki.org>
Tue, 13 Nov 2007 13:24:51 +0000 (13:24 +0000)
includes/DefaultSettings.php
includes/RawPage.php

index a79f347..c487d70 100644 (file)
@@ -1333,6 +1333,11 @@ $wgInternalServer = $wgServer;
  */
 $wgSquidMaxage = 18000;
 
+/**
+ * Default maximum age for raw CSS/JS accesses
+ */
+$wgForcedRawSMaxage = 300;
+
 /**
  * List of proxy servers to purge on changes; default port is 80. Use IP addresses.
  *
index defd74f..22a5ac4 100644 (file)
@@ -20,7 +20,7 @@ class RawPage {
        var $mContentType, $mExpandTemplates;
 
        function __construct( &$article, $request = false ) {
-               global $wgRequest, $wgInputEncoding, $wgSquidMaxage, $wgJsMimeType;
+               global $wgRequest, $wgInputEncoding, $wgSquidMaxage, $wgJsMimeType, $wgForcedRawSMaxage, $wgGroupPermissions;
 
                $allowedCTypes = array('text/x-wiki', $wgJsMimeType, 'text/css', 'application/x-zope-edit');
                $this->mArticle =& $article;
@@ -35,6 +35,7 @@ class RawPage {
                $ctype = $this->mRequest->getVal( 'ctype' );
                $smaxage = $this->mRequest->getIntOrNull( 'smaxage', $wgSquidMaxage );
                $maxage = $this->mRequest->getInt( 'maxage', $wgSquidMaxage );
+               
                $this->mExpandTemplates = $this->mRequest->getVal( 'templates' ) === 'expand';
                $this->mUseMessageCache = $this->mRequest->getBool( 'usemsgcache' );
 
@@ -81,12 +82,23 @@ class RawPage {
                        $this->mGen = false;
                }
                $this->mCharset = $wgInputEncoding;
-               $this->mSmaxage = intval( $smaxage );
+               
+               # Force caching for CSS and JS raw content, default: 5 minutes
+               if (is_null($smaxage) and ($ctype=='text/css' or $ctype==$wgJsMimeType)) {
+                       $this->mSmaxage = intval($wgForcedRawSMaxage);
+               } else {
+                       $this->mSmaxage = intval( $smaxage );
+               }
                $this->mMaxage = $maxage;
                
-               // Output may contain user-specific data; vary for open sessions
-               $this->mPrivateCache = ( $this->mSmaxage == 0 ) ||
-                       ( session_id() != '' );
+               # Output may contain user-specific data; 
+               # vary generated content for open sessions and private wikis
+               if ($this->mGen or !$wgGroupPermissions['*']['read']) {
+                       $this->mPrivateCache = ( $this->mSmaxage == 0 ) ||
+                               ( session_id() != '' );
+               } else {
+                       $this->mPrivateCache = false;
+               }
                
                if ( $ctype == '' or ! in_array( $ctype, $allowedCTypes ) ) {
                        $this->mContentType = 'text/x-wiki';