]> scripts.mit.edu Git - autoinstalls/mediawiki.git/blobdiff - includes/AjaxResponse.php
MediaWiki 1.17.0
[autoinstalls/mediawiki.git] / includes / AjaxResponse.php
index f74956669a3d2dbd520c06e6994eb09c4c642827..014798f81a3254514bbc3bf0313fdb05d3f9e878 100644 (file)
@@ -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" );