Rename setSquidMaxage() => setCdnMaxage()

Also updated the OutputPage member variable.

Change-Id: I0b41c66da58c6126c1bd96170c02d084a067383c
This commit is contained in:
Aaron Schulz 2015-12-09 17:07:05 -08:00
parent 2ce2177e50
commit f606fd8d5c
5 changed files with 25 additions and 17 deletions

View file

@ -308,7 +308,7 @@ class MediaWiki {
$targetUrl = wfExpandUrl( $title->getFullURL(), PROTO_CURRENT );
if ( $targetUrl != $request->getFullRequestURL() ) {
$output->setSquidMaxage( 1200 );
$output->setCdnMaxage( 1200 );
$output->redirect( $targetUrl, '301' );
return true;
}
@ -451,7 +451,7 @@ class MediaWiki {
$requestTitle->getSquidURLs()
)
) {
$output->setSquidMaxage( $this->config->get( 'SquidMaxage' ) );
$output->setCdnMaxage( $this->config->get( 'SquidMaxage' ) );
}
$action->show();

View file

@ -233,8 +233,8 @@ class OutputPage extends ContextSource {
private $mParseWarnings = array();
/** @var int Cache stuff. Looks like mEnableClientCache */
protected $mSquidMaxage = 0;
/** @var int Upper limit on mSquidMaxage */
protected $mCdnMaxage = 0;
/** @var int Upper limit on mCdnMaxage */
protected $mCdnMaxageLimit = INF;
/**
@ -1944,23 +1944,31 @@ class OutputPage extends ContextSource {
}
/**
* Set the value of the "s-maxage" part of the "Cache-control" HTTP header
*
* @param int $maxage Maximum cache time on the Squid, in seconds.
* @param $maxage
* @deprecated since 1.27 Use setCdnMaxage() instead
*/
public function setSquidMaxage( $maxage ) {
$this->mSquidMaxage = min( $maxage, $this->mCdnMaxageLimit );
$this->setCdnMaxage( $maxage );
}
/**
* Set the value of the "s-maxage" part of the "Cache-control" HTTP header
*
* @param int $maxage Maximum cache time on the CDN, in seconds.
*/
public function setCdnMaxage( $maxage ) {
$this->mCdnMaxage = min( $maxage, $this->mCdnMaxageLimit );
}
/**
* Lower the value of the "s-maxage" part of the "Cache-control" HTTP header
*
* @param int $maxage Maximum cache time on the Squid, in seconds
* @param int $maxage Maximum cache time on the CDN, in seconds
* @since 1.27
*/
public function lowerCdnMaxage( $maxage ) {
$this->mCdnMaxageLimit = min( $maxage, $this->mCdnMaxageLimit );
$this->setSquidMaxage( $this->mSquidMaxage );
$this->setCdnMaxage( $this->mCdnMaxage );
}
/**
@ -2181,7 +2189,7 @@ class OutputPage extends ContextSource {
if ( $this->mEnableClientCache ) {
if (
$config->get( 'UseSquid' ) && session_id() == '' && !$this->isPrintable() &&
$this->mSquidMaxage != 0 && !$this->haveCacheVaryCookies()
$this->mCdnMaxage != 0 && !$this->haveCacheVaryCookies()
) {
if ( $config->get( 'UseESI' ) ) {
# We'll purge the proxy cache explicitly, but require end user agents
@ -2191,7 +2199,7 @@ class OutputPage extends ContextSource {
# start with a shorter timeout for initial testing
# header( 'Surrogate-Control: max-age=2678400+2678400, content="ESI/1.0"');
$response->header( 'Surrogate-Control: max-age=' . $config->get( 'SquidMaxage' )
. '+' . $this->mSquidMaxage . ', content="ESI/1.0"' );
. '+' . $this->mCdnMaxage . ', content="ESI/1.0"' );
$response->header( 'Cache-Control: s-maxage=0, must-revalidate, max-age=0' );
} else {
# We'll purge the proxy cache for anons explicitly, but require end user agents
@ -2201,7 +2209,7 @@ class OutputPage extends ContextSource {
wfDebug( __METHOD__ . ": local proxy caching; {$this->mLastModified} **\n", 'log' );
# start with a shorter timeout for initial testing
# header( "Cache-Control: s-maxage=2678400, must-revalidate, max-age=0" );
$response->header( 'Cache-Control: s-maxage=' . $this->mSquidMaxage
$response->header( 'Cache-Control: s-maxage=' . $this->mCdnMaxage
. ', must-revalidate, max-age=0' );
}
} else {

View file

@ -696,7 +696,7 @@ class Article implements Page {
# Don't cache a dirty ParserOutput object
if ( $poolArticleView->getIsDirty() ) {
$outputPage->setSquidMaxage( 0 );
$outputPage->setCdnMaxage( 0 );
$outputPage->addHTML( "<!-- parser cache is expired, " .
"sending anyway due to pool overload-->\n" );
}

View file

@ -1446,7 +1446,7 @@ abstract class Skin extends ContextSource {
}
$newMessagesAlert = $newMessagesAlert->text();
# Disable Squid cache
$out->setSquidMaxage( 0 );
$out->setCdnMaxage( 0 );
} elseif ( count( $newtalks ) ) {
$sep = $this->msg( 'newtalkseparator' )->escaped();
$msgs = array();
@ -1459,7 +1459,7 @@ abstract class Skin extends ContextSource {
}
$parts = implode( $sep, $msgs );
$newMessagesAlert = $this->msg( 'youhavenewmessagesmulti' )->rawParams( $parts )->escaped();
$out->setSquidMaxage( 0 );
$out->setCdnMaxage( 0 );
}
return $newMessagesAlert;

View file

@ -50,7 +50,7 @@ class SpecialRecentChanges extends ChangesListSpecialPage {
}
// 10 seconds server-side caching max
$this->getOutput()->setSquidMaxage( 10 );
$this->getOutput()->setCdnMaxage( 10 );
// Check if the client has a cached version
$lastmod = $this->checkLastModified();
if ( $lastmod === false ) {