From cd0a89520dec7b2c5de5ff5a519e083bd546a798 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Thu, 3 Jul 2003 10:18:07 +0000 Subject: [PATCH] Fixes missing cache-control and last-modified headers with file cached pages. 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 | 3 ++- includes/OutputPage.php | 27 ++++++++++++++++----------- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/includes/Article.php b/includes/Article.php index 797ceae6b7..5edfe690a1 100644 --- a/includes/Article.php +++ b/includes/Article.php @@ -1640,7 +1640,7 @@ name=\"wpSummary\" maxlength=200 size=60>
} 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>
header( "Vary: Accept-Encoding" ); $filename = $filenamegz; } + $wgOut->sendCacheControl(); readfile( $filename ); } diff --git a/includes/OutputPage.php b/includes/OutputPage.php index 2ce3041645..bb12b4c8ce 100644 --- a/includes/OutputPage.php +++ b/includes/OutputPage.php @@ -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 ); -- 2.20.1