From 4348c0b3206b90190e84742f5dc842b687d18069 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Sat, 2 Aug 2003 12:41:30 +0000 Subject: [PATCH] Slight cache tweaks; fixes gzip encoding header for newly recached pages on my home test box (worked fine on the real install anyway, but...) --- includes/Article.php | 7 +++++++ includes/CacheManager.php | 12 +++++------- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/includes/Article.php b/includes/Article.php index 580d75d60a..03a0386200 100644 --- a/includes/Article.php +++ b/includes/Article.php @@ -1633,6 +1633,13 @@ $wgLang->recodeForEdit( $wpTextbox1 ) . exit; } else { wfDebug( " tryFileCache() - starting buffer\n" ); + if($cache->useGzip()) { + /* For some reason, adding this header line over in + CacheManager::saveToFileCache() fails on my test + setup at home, though it works on the live install. + Make double-sure... --brion */ + header( "Content-Encoding: gzip" ); + } ob_start( array(&$cache, 'saveToFileCache' ) ); } } else { diff --git a/includes/CacheManager.php b/includes/CacheManager.php index f42c530460..225cacef0e 100644 --- a/includes/CacheManager.php +++ b/includes/CacheManager.php @@ -39,7 +39,7 @@ class CacheManager { } function isFileCacheGood( $timestamp ) { - global $wgUser, $wgCacheEpoch; + global $wgCacheEpoch; if( !$this->isFileCached() ) return false; @@ -47,7 +47,7 @@ class CacheManager { $good = (( $timestamp <= $cachetime ) && ( $wgCacheEpoch <= $cachetime )); - wfDebug(" isFileCacheGood() - cachetime $cachetime, touched {$this->mTouched} epoch {$wgCacheEpoch}, good $good\n"); + wfDebug(" isFileCacheGood() - cachetime $cachetime, touched {$timestamp} epoch {$wgCacheEpoch}, good $good\n"); return $good; } @@ -81,19 +81,18 @@ class CacheManager { if( $this->useGzip() ) { if( wfClientAcceptsGzip() ) { header( "Content-Encoding: gzip" ); - readfile( $filename ); } else { /* Send uncompressed */ readgzfile( $filename ); + return; } - } else { - readfile( $filename ); } + readfile( $filename ); } function checkCacheDirs() { $filename = $this->fileCacheName(); - $mydir2=substr($filename,0,strrpos($filename,"/")); # subdirectory level 2 + $mydir2=substr($filename,0,strrpos($filename,"/")); # subdirectory level 2 $mydir1=substr($mydir2,0,strrpos($mydir2,"/")); # subdirectory level 1 if(!file_exists($mydir1)) { mkdir($mydir1,0775); } # create if necessary @@ -125,7 +124,6 @@ class CacheManager { if( $this->useGzip() ) { if( wfClientAcceptsGzip() ) { header( "Content-Encoding: gzip" ); - header( "Vary: Accept-Encoding" ); return $text; } else { return $rawtext; -- 2.20.1