X-Git-Url: http://git.cyclocoop.org/?a=blobdiff_plain;f=includes%2FAjaxResponse.php;h=b9f8085557adac62221c731d84a862ca83c1c3d4;hb=bd756e66843bd1f346ebfed21d11996fde92ba62;hp=f74956669a3d2dbd520c06e6994eb09c4c642827;hpb=f8b1c4cfb7a9f55e94751ad89306f7712391c38e;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/AjaxResponse.php b/includes/AjaxResponse.php index f74956669a..b9f8085557 100644 --- a/includes/AjaxResponse.php +++ b/includes/AjaxResponse.php @@ -1,13 +1,11 @@ mLastModified ) { header ( "Last-Modified: " . $this->mLastModified ); - } - else { + } else { header ( "Last-Modified: " . gmdate( "D, d M Y H:i:s" ) . " GMT" ); } if ( $this->mCacheDuration ) { - # If squid caches are configured, tell them to cache the response, # and tell the client to always check with the squid. Otherwise, # tell the client to use a cached copy, without a way to purge it. if ( $wgUseSquid ) { - # Expect explicite purge of the proxy cache, but require end user agents # to revalidate against the proxy on each visit. # Surrogate-Control controls our Squid, Cache-Control downstream caches @@ -127,7 +121,7 @@ class AjaxResponse { # Let the client do the caching. Cache is not purged. header ( "Expires: " . gmdate( "D, d M Y H:i:s", time() + $this->mCacheDuration ) . " GMT" ); - header ( "Cache-Control: s-max-age={$this->mCacheDuration},public,max-age={$this->mCacheDuration}" ); + header ( "Cache-Control: s-maxage={$this->mCacheDuration},public,max-age={$this->mCacheDuration}" ); } } else { @@ -156,10 +150,12 @@ class AjaxResponse { wfDebug( "$fname: CACHE DISABLED, NO TIMESTAMP\n" ); return; } + if ( !$wgCachePages ) { wfDebug( "$fname: CACHE DISABLED\n", false ); return; } + if ( $wgUser->getOption( 'nocache' ) ) { wfDebug( "$fname: USER DISABLED CACHE\n", false ); return; @@ -177,6 +173,7 @@ class AjaxResponse { $ismodsince = wfTimestamp( TS_MW, $modsinceTime ? $modsinceTime : 1 ); wfDebug( "$fname: -- client send If-Modified-Since: " . $modsince . "\n", false ); wfDebug( "$fname: -- we might send Last-Modified : $lastmod\n", false ); + if ( ( $ismodsince >= $timestamp ) && $wgUser->validateCache( $ismodsince ) && $ismodsince >= $wgCacheEpoch ) { ini_set( 'zlib.output_compression', 0 ); $this->setResponseCode( "304 Not Modified" ); @@ -198,7 +195,10 @@ class AjaxResponse { function loadFromMemcached( $mckey, $touched ) { global $wgMemc; - if ( !$touched ) return false; + + if ( !$touched ) { + return false; + } $mcvalue = $wgMemc->get( $mckey ); if ( $mcvalue ) { @@ -206,6 +206,7 @@ class AjaxResponse { if ( $touched <= $mcvalue['timestamp'] ) { wfDebug( "Got $mckey from cache\n" ); $this->mText = $mcvalue['value']; + return true; } else { wfDebug( "$mckey has expired\n" );