Account for $wgSquidMaxage in OutputPage::checkLastModified().
authorAaron Schulz <aschulz@wikimedia.org>
Tue, 9 Apr 2013 20:55:36 +0000 (13:55 -0700)
committerGerrit Code Review <gerrit@wikimedia.org>
Tue, 16 Apr 2013 06:53:10 +0000 (06:53 +0000)
* This deals with the fact that seldom edited pages can end up cached
  with very stale resource (JS/CSS) references since the response to
  IMS GET requests will be 304 Not Modified if page_touched is ancient.
  When squid revalidates its stale cache it will keep getting 304s and
  renewing the TTL on the stale cache.

Bug: 44570
Change-Id: I3889f300012aeabd37e228653279ad19b296e4ae

includes/OutputPage.php

index 8bf6443..9f911d5 100644 (file)
@@ -687,7 +687,7 @@ class OutputPage extends ContextSource {
         * @return Boolean: true iff cache-ok headers was sent.
         */
        public function checkLastModified( $timestamp ) {
-               global $wgCachePages, $wgCacheEpoch;
+               global $wgCachePages, $wgCacheEpoch, $wgUseSquid, $wgSquidMaxage;
 
                if ( !$timestamp || $timestamp == '19700101000000' ) {
                        wfDebug( __METHOD__ . ": CACHE DISABLED, NO TIMESTAMP\n" );
@@ -704,10 +704,14 @@ class OutputPage extends ContextSource {
 
                $timestamp = wfTimestamp( TS_MW, $timestamp );
                $modifiedTimes = array(
-                       'page' => $timestamp,
-                       'user' => $this->getUser()->getTouched(),
-                       'epoch' => $wgCacheEpoch
+                       'page'   => $timestamp,
+                       'user'   => $this->getUser()->getTouched(),
+                       'epoch'  => $wgCacheEpoch
                );
+               if ( $wgUseSquid ) {
+                       // bug 44570: the core page itself may not change, but resources might
+                       $modifiedTimes['sepoch'] = wfTimestamp( TS_MW, time() - $wgSquidMaxage );
+               }
                wfRunHooks( 'OutputPageCheckLastModified', array( &$modifiedTimes ) );
 
                $maxModified = max( $modifiedTimes );