Fixes missing cache-control and last-modified headers with file cached pages.
authorBrion Vibber <brion@users.mediawiki.org>
Thu, 3 Jul 2003 10:18:07 +0000 (10:18 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Thu, 3 Jul 2003 10:18:07 +0000 (10:18 +0000)
HOWEVER, the session cookie seems to override our cache control. May need to
mess with this to get things working smoothly.

Also, caching + gzip may be a difficult combination.

includes/Article.php
includes/OutputPage.php

index 797ceae..5edfe69 100644 (file)
@@ -1640,7 +1640,7 @@ name=\"wpSummary\" maxlength=200 size=60><br>
        }
 
        function loadFromFileCache() {
-               global $wgUseGzip;
+               global $wgUseGzip, $wgOut;
                wfDebug(" loadFromFileCache()\n");
                $filename=$this->fileCacheName();
                $filenamegz = "{$filename}.gz";
@@ -1653,6 +1653,7 @@ name=\"wpSummary\" maxlength=200 size=60><br>
                        header( "Vary: Accept-Encoding" );
                        $filename = $filenamegz;
                }
+               $wgOut->sendCacheControl();
                readfile( $filename );
        }
        
index 2ce3041..bb12b4c 100644 (file)
@@ -303,6 +303,18 @@ class OutputPage {
                wfProfileOut();
        }
 
+       function sendCacheControl() {
+               if( $this->mLastModified != "" ) {
+                       header( "Cache-Control: private, must-revalidate, max-age=0" );
+                       header( "Last-modified: {$this->mLastModified}" );
+               } else {
+                       header( "Cache-Control: no-cache" ); # Experimental - see below
+                       header( "Pragma: no-cache" );
+                       header( "Last-modified: " . gmdate( "D, j M Y H:i:s" ) . " GMT" );
+               }
+               header( "Expires: Mon, 15 Jan 2001 00:00:00 GMT" ); # Cachers always validate the page!
+       }
+       
        # Finally, all the text has been munged and accumulated into
        # the object, let's actually output it:
        #
@@ -314,15 +326,7 @@ class OutputPage {
                $sk = $wgUser->getSkin();
 
                wfProfileIn( "OutputPage::output-headers" );
-               if( $this->mLastModified != "" ) {
-                       header( "Cache-Control: private, must-revalidate, max-age=0" );
-                       header( "Last-modified: {$this->mLastModified}" );
-               } else {
-                       header( "Cache-Control: no-cache" ); # Experimental - see below
-                       header( "Pragma: no-cache" );
-                       header( "Last-modified: " . gmdate( "D, j M Y H:i:s" ) . " GMT" );
-               }
-               header( "Expires: Mon, 15 Jan 2001 00:00:00 GMT" ); # Cachers always validate the page!
+               $this->sendCacheControl();
 
                header( "Content-type: text/html; charset={$wgOutputEncoding}" );
                header( "Content-language: {$wgLanguageCode}" );
@@ -649,7 +653,7 @@ class OutputPage {
        #
        function doWikiPass2( $text, $linestart )
        {
-               global $wgUser, $wgLang;
+               global $wgUser, $wgLang, $wgMungeDates;
                wfProfileIn( "OutputPage::doWikiPass2" );
                
                $text = $this->removeHTMLtags( $text );
@@ -662,7 +666,8 @@ class OutputPage {
                $text = $this->doHeadings( $text );
                $text = $this->doBlockLevels( $text, $linestart );
                
-               $text = $wgLang->replaceDates( $text );
+               if($wgMungeDates)
+                       $text = $wgLang->replaceDates( $text );
                $text = $this->replaceExternalLinks( $text );
                $text = $this->replaceInternalLinks ( $text );