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

View file

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

View file

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

View file

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

View file

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