From 3082af54722d6688b1298736e041ea68e061013d Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Tue, 9 Apr 2013 13:55:36 -0700 Subject: [PATCH] Account for $wgSquidMaxage in OutputPage::checkLastModified(). * 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 | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/includes/OutputPage.php b/includes/OutputPage.php index 8bf644353b..9f911d5892 100644 --- a/includes/OutputPage.php +++ b/includes/OutputPage.php @@ -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 ); -- 2.20.1