summaryrefslogtreecommitdiff
path: root/includes/AjaxResponse.php
diff options
context:
space:
mode:
Diffstat (limited to 'includes/AjaxResponse.php')
-rw-r--r--includes/AjaxResponse.php19
1 files changed, 12 insertions, 7 deletions
diff --git a/includes/AjaxResponse.php b/includes/AjaxResponse.php
index f7495666..014798f8 100644
--- a/includes/AjaxResponse.php
+++ b/includes/AjaxResponse.php
@@ -1,5 +1,7 @@
<?php
/**
+ * Response handler for Ajax requests
+ *
* @file
* @ingroup Ajax
*/
@@ -15,7 +17,6 @@ if ( !defined( 'MEDIAWIKI' ) ) {
* @ingroup Ajax
*/
class AjaxResponse {
-
/** Number of seconds to get the response cached by a proxy */
private $mCacheDuration;
@@ -99,19 +100,16 @@ class AjaxResponse {
if ( $this->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 +125,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 +154,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 +177,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 +199,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 +210,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" );