Merge "Rename CDN config variables to be generic, deprecating the old names"
This commit is contained in:
commit
c1bfb7d319
20 changed files with 151 additions and 80 deletions
|
|
@ -35,6 +35,13 @@ For notes on 1.33.x and older releases, see HISTORY.
|
|||
module or will be generated by Mediawiki itself (depending on the set-up).
|
||||
|
||||
==== Changed configuration ====
|
||||
* $wgUseCdn, $wgCdnServers, $wgCdnServersNoPurge, and $wgCdnMaxAge – These four
|
||||
CDN-related config variables have been renamed from being specific to Squid –
|
||||
they were previously $wgUseSquid, $wgSquidServers, $wgSquidServersNoPurge, and
|
||||
$wgSquidMaxage respectively. This aligns them with the related existing
|
||||
variable $wgCdnMaxageLagged. The previous configuration variable names are
|
||||
deprecated, but will be used as the fall back if they are still set.
|
||||
Note that wgSquidPurgeUseHostHeader has not been renamed, as it is deprecated.
|
||||
* …
|
||||
|
||||
==== Removed configuration ====
|
||||
|
|
|
|||
|
|
@ -179,8 +179,7 @@ class AjaxResponse {
|
|||
# If CDN caches are configured, tell them to cache the response,
|
||||
# and tell the client to always check with the CDN. Otherwise,
|
||||
# tell the client to use a cached copy, without a way to purge it.
|
||||
|
||||
if ( $this->mConfig->get( 'UseSquid' ) ) {
|
||||
if ( $this->mConfig->get( 'UseCdn' ) ) {
|
||||
# Expect explicit purge of the proxy cache, but require end user agents
|
||||
# to revalidate against the proxy on each visit.
|
||||
# Surrogate-Control controls our CDN, Cache-Control downstream caches
|
||||
|
|
|
|||
|
|
@ -1154,7 +1154,7 @@ class Block extends AbstractBlock {
|
|||
if ( !IP::isValid( $ipaddr ) ) {
|
||||
continue;
|
||||
}
|
||||
# Don't check trusted IPs (includes local squids which will be in every request)
|
||||
# Don't check trusted IPs (includes local CDNs which will be in every request)
|
||||
if ( $proxyLookup->isTrustedProxy( $ipaddr ) ) {
|
||||
continue;
|
||||
}
|
||||
|
|
@ -1215,7 +1215,7 @@ class Block extends AbstractBlock {
|
|||
* @param array $ipChain List of IPs (strings). This is used to determine how "close"
|
||||
* a block is to the server, and if a block matches exactly, or is in a range.
|
||||
* The order is furthest from the server to nearest e.g., (Browser, proxy1, proxy2,
|
||||
* local-squid, ...)
|
||||
* local-cdn, ...)
|
||||
* @throws MWException
|
||||
* @return Block|null The "best" block from the list
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -2701,7 +2701,8 @@ $wgExtensionInfoMTime = false;
|
|||
* @name HTTP proxy (CDN) settings
|
||||
*
|
||||
* Many of these settings apply to any HTTP proxy used in front of MediaWiki,
|
||||
* although they are referred to as Squid settings for historical reasons.
|
||||
* although they are sometimes still referred to as Squid settings for
|
||||
* historical reasons.
|
||||
*
|
||||
* Achieving a high hit ratio with an HTTP proxy requires special
|
||||
* configuration. See https://www.mediawiki.org/wiki/Manual:Squid_caching for
|
||||
|
|
@ -2713,8 +2714,10 @@ $wgExtensionInfoMTime = false;
|
|||
/**
|
||||
* Enable/disable CDN.
|
||||
* See https://www.mediawiki.org/wiki/Manual:Squid_caching
|
||||
*
|
||||
* @since 1.34 Renamed from $wgUseSquid.
|
||||
*/
|
||||
$wgUseSquid = false;
|
||||
$wgUseCdn = false;
|
||||
|
||||
/**
|
||||
* If you run Squid3 with ESI support, enable this (default:false):
|
||||
|
|
@ -2756,12 +2759,15 @@ $wgInternalServer = false;
|
|||
* out s-maxage in the CDN config.
|
||||
*
|
||||
* 18000 seconds = 5 hours, more cache hits with 2678400 = 31 days.
|
||||
*
|
||||
* @since 1.34 Renamed from $wgSquidMaxage
|
||||
*/
|
||||
$wgSquidMaxage = 18000;
|
||||
$wgCdnMaxAge = 18000;
|
||||
|
||||
/**
|
||||
* Cache timeout for the CDN when DB replica DB lag is high
|
||||
* @see $wgSquidMaxage
|
||||
* @see $wgCdnMaxAge
|
||||
*
|
||||
* @since 1.27
|
||||
*/
|
||||
$wgCdnMaxageLagged = 30;
|
||||
|
|
@ -2784,7 +2790,7 @@ $wgCdnReboundPurgeDelay = 0;
|
|||
|
||||
/**
|
||||
* Cache timeout for the CDN when a response is known to be wrong or incomplete (due to load)
|
||||
* @see $wgSquidMaxage
|
||||
* @see $wgCdnMaxAge
|
||||
* @since 1.27
|
||||
*/
|
||||
$wgCdnMaxageSubstitute = 60;
|
||||
|
|
@ -2803,20 +2809,24 @@ $wgForcedRawSMaxage = 300;
|
|||
* headers sent/modified from these proxies when obtaining the remote IP address
|
||||
*
|
||||
* For a list of trusted servers which *aren't* purged, see $wgSquidServersNoPurge.
|
||||
*
|
||||
* @since 1.34 Renamed from $wgSquidServers.
|
||||
*/
|
||||
$wgSquidServers = [];
|
||||
$wgCdnServers = [];
|
||||
|
||||
/**
|
||||
* As above, except these servers aren't purged on page changes; use to set a
|
||||
* list of trusted proxies, etc. Supports both individual IP addresses and
|
||||
* CIDR blocks.
|
||||
* As with $wgCdnServers, except these servers aren't purged on page changes;
|
||||
* use to set a list of trusted proxies, etc. Supports both individual IP
|
||||
* addresses and CIDR blocks.
|
||||
*
|
||||
* @since 1.23 Supports CIDR ranges
|
||||
* @since 1.34 Renamed from $wgSquidServersNoPurge
|
||||
*/
|
||||
$wgSquidServersNoPurge = [];
|
||||
$wgCdnServersNoPurge = [];
|
||||
|
||||
/**
|
||||
* Whether to use a Host header in purge requests sent to the proxy servers
|
||||
* configured in $wgSquidServers. Set this to false to support Squid
|
||||
* configured in $wgCdnServers. Set this to false to support a CDN
|
||||
* configured in forward-proxy mode.
|
||||
*
|
||||
* If this is set to true, a Host header will be sent, and only the path
|
||||
|
|
@ -6505,7 +6515,7 @@ $wgCachePrefix = false;
|
|||
/**
|
||||
* Display the new debugging toolbar. This also enables profiling on database
|
||||
* queries and other useful output.
|
||||
* Will be ignored if $wgUseFileCache or $wgUseSquid is enabled.
|
||||
* Will be ignored if $wgUseFileCache or $wgUseCdn is enabled.
|
||||
*
|
||||
* @since 1.19
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -486,14 +486,14 @@ class MediaWiki {
|
|||
}
|
||||
|
||||
# Let CDN cache things if we can purge them.
|
||||
if ( $this->config->get( 'UseSquid' ) &&
|
||||
if ( $this->config->get( 'UseCdn' ) &&
|
||||
in_array(
|
||||
// Use PROTO_INTERNAL because that's what getCdnUrls() uses
|
||||
wfExpandUrl( $request->getRequestURL(), PROTO_INTERNAL ),
|
||||
$requestTitle->getCdnUrls()
|
||||
)
|
||||
) {
|
||||
$output->setCdnMaxage( $this->config->get( 'SquidMaxage' ) );
|
||||
$output->setCdnMaxage( $this->config->get( 'CdnMaxAge' ) );
|
||||
}
|
||||
|
||||
$action->show();
|
||||
|
|
|
|||
|
|
@ -746,10 +746,10 @@ class OutputPage extends ContextSource {
|
|||
'user' => $this->getUser()->getTouched(),
|
||||
'epoch' => $config->get( 'CacheEpoch' )
|
||||
];
|
||||
if ( $config->get( 'UseSquid' ) ) {
|
||||
if ( $config->get( 'UseCdn' ) ) {
|
||||
$modifiedTimes['sepoch'] = wfTimestamp( TS_MW, $this->getCdnCacheEpoch(
|
||||
time(),
|
||||
$config->get( 'SquidMaxage' )
|
||||
$config->get( 'CdnMaxAge' )
|
||||
) );
|
||||
}
|
||||
Hooks::run( 'OutputPageCheckLastModified', [ &$modifiedTimes, $this ] );
|
||||
|
|
@ -818,7 +818,7 @@ class OutputPage extends ContextSource {
|
|||
* @return int Timestamp
|
||||
*/
|
||||
private function getCdnCacheEpoch( $reqTime, $maxAge ) {
|
||||
// Ensure Last-Modified is never more than (wgSquidMaxage) in the past,
|
||||
// Ensure Last-Modified is never more than $wgCdnMaxAge in the past,
|
||||
// because even if the wiki page content hasn't changed since, static
|
||||
// resources may have changed (skin HTML, interface messages, urls, etc.)
|
||||
// and must roll-over in a timely manner (T46570)
|
||||
|
|
@ -2248,12 +2248,12 @@ class OutputPage extends ContextSource {
|
|||
*
|
||||
* @param string|int|float|bool|null $mtime Last-Modified timestamp
|
||||
* @param int $minTTL Minimum TTL in seconds [default: 1 minute]
|
||||
* @param int $maxTTL Maximum TTL in seconds [default: $wgSquidMaxage]
|
||||
* @param int $maxTTL Maximum TTL in seconds [default: $wgCdnMaxAge]
|
||||
* @since 1.28
|
||||
*/
|
||||
public function adaptCdnTTL( $mtime, $minTTL = 0, $maxTTL = 0 ) {
|
||||
$minTTL = $minTTL ?: IExpiringStore::TTL_MINUTE;
|
||||
$maxTTL = $maxTTL ?: $this->getConfig()->get( 'SquidMaxage' );
|
||||
$maxTTL = $maxTTL ?: $this->getConfig()->get( 'CdnMaxAge' );
|
||||
|
||||
if ( $mtime === null || $mtime === false ) {
|
||||
return $minTTL; // entity does not exist
|
||||
|
|
@ -2567,7 +2567,7 @@ class OutputPage extends ContextSource {
|
|||
|
||||
if ( $this->mEnableClientCache ) {
|
||||
if (
|
||||
$config->get( 'UseSquid' ) &&
|
||||
$config->get( 'UseCdn' ) &&
|
||||
!$response->hasCookies() &&
|
||||
!SessionManager::getGlobalSession()->isPersistent() &&
|
||||
!$this->isPrintable() &&
|
||||
|
|
@ -2584,7 +2584,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' )}" .
|
||||
"Surrogate-Control: max-age={$config->get( 'CdnMaxAge' )}" .
|
||||
"+{$this->mCdnMaxage}, content=\"ESI/1.0\""
|
||||
);
|
||||
$response->header( 'Cache-Control: s-maxage=0, must-revalidate, max-age=0' );
|
||||
|
|
|
|||
|
|
@ -484,8 +484,8 @@ return [
|
|||
'ProxyLookup' => function ( MediaWikiServices $services ) : ProxyLookup {
|
||||
$mainConfig = $services->getMainConfig();
|
||||
return new ProxyLookup(
|
||||
$mainConfig->get( 'SquidServers' ),
|
||||
$mainConfig->get( 'SquidServersNoPurge' )
|
||||
$mainConfig->get( 'CdnServers' ),
|
||||
$mainConfig->get( 'CdnServersNoPurge' )
|
||||
);
|
||||
},
|
||||
|
||||
|
|
|
|||
|
|
@ -518,9 +518,61 @@ foreach ( LanguageCode::getNonstandardLanguageCodeMapping() as $code => $bcp47 )
|
|||
// To determine the user language, use $wgLang->getCode()
|
||||
$wgContLanguageCode = $wgLanguageCode;
|
||||
|
||||
// Temporary backwards-compatibility reading of old Squid-named CDN settings as of MediaWiki 1.34,
|
||||
// to support sysadmins who fail to update their settings immediately:
|
||||
|
||||
if ( isset( $wgUseSquid ) ) {
|
||||
// If the sysadmin is still setting a value of $wgUseSquid to true but $wgUseCdn is the default of
|
||||
// false, to be safe, assume they do want this still, so enable it.
|
||||
if ( !$wgUseCdn && $wgUseSquid ) {
|
||||
$wgUseCdn = $wgUseSquid;
|
||||
wfDeprecated( '$wgUseSquid enabled but $wgUseCdn disabled; enabling CDN functions', '1.34' );
|
||||
}
|
||||
} else {
|
||||
// Backwards-compatibility for extensions that read this value.
|
||||
$wgUseSquid = $wgUseCdn;
|
||||
}
|
||||
|
||||
if ( isset( $wgSquidServers ) ) {
|
||||
// If the sysadmin is still setting a value of $wgSquidServers but $wgCdnServers is the default of
|
||||
// empty, to be safe, assume they do want these servers to be still used, so use them.
|
||||
if ( !empty( $wgSquidServers ) && empty( $wgCdnServers ) ) {
|
||||
$wgCdnServers = $wgSquidServers;
|
||||
wfDeprecated( '$wgSquidServers set, $wgCdnServers empty; using them', '1.34' );
|
||||
}
|
||||
} else {
|
||||
// Backwards-compatibility for extensions that read this value.
|
||||
$wgSquidServers = $wgCdnServers;
|
||||
}
|
||||
|
||||
if ( isset( $wgSquidServersNoPurge ) ) {
|
||||
// If the sysadmin is still setting values in $wgSquidServersNoPurge but $wgCdnServersNoPurge is
|
||||
// the default of empty, to be safe, assume they do want these servers to be still used, so use
|
||||
// them.
|
||||
if ( !empty( $wgSquidServersNoPurge ) && empty( $wgCdnServersNoPurge ) ) {
|
||||
$wgCdnServersNoPurge = $wgSquidServersNoPurge;
|
||||
wfDeprecated( '$wgSquidServersNoPurge set, $wgCdnServersNoPurge empty; using them', '1.34' );
|
||||
}
|
||||
} else {
|
||||
// Backwards-compatibility for extensions that read this value.
|
||||
$wgSquidServersNoPurge = $wgCdnServersNoPurge;
|
||||
}
|
||||
|
||||
if ( isset( $wgSquidMaxage ) ) {
|
||||
// If the sysadmin is still setting a value of $wgSquidMaxage and it's higher than $wgCdnMaxAge,
|
||||
// to be safe, assume they want the higher (lower performance requirement) value, so use that.
|
||||
if ( $wgCdnMaxAge < $wgSquidMaxage ) {
|
||||
$wgCdnMaxAge = $wgSquidMaxage;
|
||||
wfDeprecated( '$wgSquidMaxage set higher than $wgCdnMaxAge; using the higher value', '1.34' );
|
||||
}
|
||||
} else {
|
||||
// Backwards-compatibility for extensions that read this value.
|
||||
$wgSquidMaxage = $wgCdnMaxAge;
|
||||
}
|
||||
|
||||
// Easy to forget to falsify $wgDebugToolbar for static caches.
|
||||
// If file cache or CDN cache is on, just disable this (DWIMD).
|
||||
if ( $wgUseFileCache || $wgUseSquid ) {
|
||||
if ( $wgUseFileCache || $wgUseCdn ) {
|
||||
$wgDebugToolbar = false;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ class RawAction extends FormlessAction {
|
|||
|
||||
$contentType = $this->getContentType();
|
||||
|
||||
$maxage = $request->getInt( 'maxage', $config->get( 'SquidMaxage' ) );
|
||||
$maxage = $request->getInt( 'maxage', $config->get( 'CdnMaxAge' ) );
|
||||
$smaxage = $request->getIntOrNull( 'smaxage' );
|
||||
if ( $smaxage === null ) {
|
||||
if (
|
||||
|
|
|
|||
|
|
@ -148,7 +148,7 @@ class ApiMain extends ApiBase {
|
|||
private $mContinuationManager;
|
||||
private $mAction;
|
||||
private $mEnableWrite;
|
||||
private $mInternalMode, $mSquidMaxage;
|
||||
private $mInternalMode, $mCdnMaxAge;
|
||||
/** @var ApiBase */
|
||||
private $mModule;
|
||||
|
||||
|
|
@ -288,7 +288,7 @@ class ApiMain extends ApiBase {
|
|||
$this->mContinuationManager = null;
|
||||
$this->mEnableWrite = $enableWrite;
|
||||
|
||||
$this->mSquidMaxage = -1; // flag for executeActionWithErrorHandling()
|
||||
$this->mCdnMaxAge = -1; // flag for executeActionWithErrorHandling()
|
||||
$this->mCommit = false;
|
||||
}
|
||||
|
||||
|
|
@ -1368,18 +1368,20 @@ class ApiMain extends ApiBase {
|
|||
$ts->format( 'D M j H:i:s Y' ) === $value ||
|
||||
$ts->format( 'D M j H:i:s Y' ) === $value
|
||||
) {
|
||||
$config = $this->getConfig();
|
||||
$lastMod = $module->getConditionalRequestData( 'last-modified' );
|
||||
if ( $lastMod !== null ) {
|
||||
// Mix in some MediaWiki modification times
|
||||
$modifiedTimes = [
|
||||
'page' => $lastMod,
|
||||
'user' => $this->getUser()->getTouched(),
|
||||
'epoch' => $this->getConfig()->get( 'CacheEpoch' ),
|
||||
'epoch' => $config->get( 'CacheEpoch' ),
|
||||
];
|
||||
if ( $this->getConfig()->get( 'UseSquid' ) ) {
|
||||
|
||||
if ( $config->get( 'UseCdn' ) ) {
|
||||
// T46570: the core page itself may not change, but resources might
|
||||
$modifiedTimes['sepoch'] = wfTimestamp(
|
||||
TS_MW, time() - $this->getConfig()->get( 'SquidMaxage' )
|
||||
TS_MW, time() - $config->get( 'CdnMaxAge' )
|
||||
);
|
||||
}
|
||||
Hooks::run( 'OutputPageCheckLastModified', [ &$modifiedTimes, $this->getOutput() ] );
|
||||
|
|
|
|||
|
|
@ -150,7 +150,7 @@ class SquidPurgeClient {
|
|||
if ( IP::isIPv4( $this->host ) ) {
|
||||
$this->ip = $this->host;
|
||||
} elseif ( IP::isIPv6( $this->host ) ) {
|
||||
throw new MWException( '$wgSquidServers does not support IPv6' );
|
||||
throw new MWException( '$wgCdnServers does not support IPv6' );
|
||||
} else {
|
||||
Wikimedia\suppressWarnings();
|
||||
$this->ip = gethostbyname( $this->host );
|
||||
|
|
|
|||
|
|
@ -79,14 +79,14 @@ class CdnCacheUpdate implements DeferrableUpdate, MergeableUpdate {
|
|||
}
|
||||
|
||||
/**
|
||||
* Purges a list of CDN nodes defined in $wgSquidServers.
|
||||
* Purges a list of CDN nodes defined in $wgCdnServers.
|
||||
* $urlArr should contain the full URLs to purge as values
|
||||
* (example: $urlArr[] = 'http://my.host/something')
|
||||
*
|
||||
* @param string[] $urlArr List of full URLs to purge
|
||||
*/
|
||||
public static function purge( array $urlArr ) {
|
||||
global $wgSquidServers, $wgHTCPRouting;
|
||||
global $wgCdnServers, $wgHTCPRouting;
|
||||
|
||||
if ( !$urlArr ) {
|
||||
return;
|
||||
|
|
@ -120,20 +120,20 @@ class CdnCacheUpdate implements DeferrableUpdate, MergeableUpdate {
|
|||
}
|
||||
|
||||
// Do direct server purges if enabled (this does not scale very well)
|
||||
if ( $wgSquidServers ) {
|
||||
// Maximum number of parallel connections per squid
|
||||
$maxSocketsPerSquid = 8;
|
||||
if ( $wgCdnServers ) {
|
||||
// Maximum number of parallel connections per CDN
|
||||
$maxSocketsPerCdn = 8;
|
||||
// Number of requests to send per socket
|
||||
// 400 seems to be a good tradeoff, opening a socket takes a while
|
||||
$urlsPerSocket = 400;
|
||||
$socketsPerSquid = ceil( count( $urlArr ) / $urlsPerSocket );
|
||||
if ( $socketsPerSquid > $maxSocketsPerSquid ) {
|
||||
$socketsPerSquid = $maxSocketsPerSquid;
|
||||
$socketsPerCdn = ceil( count( $urlArr ) / $urlsPerSocket );
|
||||
if ( $socketsPerCdn > $maxSocketsPerCdn ) {
|
||||
$socketsPerCdn = $maxSocketsPerCdn;
|
||||
}
|
||||
|
||||
$pool = new SquidPurgeClientPool;
|
||||
$chunks = array_chunk( $urlArr, ceil( count( $urlArr ) / $socketsPerSquid ) );
|
||||
foreach ( $wgSquidServers as $server ) {
|
||||
$chunks = array_chunk( $urlArr, ceil( count( $urlArr ) / $socketsPerCdn ) );
|
||||
foreach ( $wgCdnServers as $server ) {
|
||||
foreach ( $chunks as $chunk ) {
|
||||
$client = new SquidPurgeClient( $server );
|
||||
foreach ( $chunk as $url ) {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
/**
|
||||
* Benchmark for Squid purge.
|
||||
* Benchmark for CDN purge.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
|
@ -24,22 +24,23 @@
|
|||
require_once __DIR__ . '/Benchmarker.php';
|
||||
|
||||
/**
|
||||
* Maintenance script that benchmarks Squid purge.
|
||||
* Maintenance script that benchmarks CDN purge.
|
||||
*
|
||||
* @ingroup Benchmark
|
||||
*/
|
||||
class BenchmarkPurge extends Benchmarker {
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
$this->addDescription( 'Benchmark the Squid purge functions.' );
|
||||
$this->addDescription( 'Benchmark the CDN purge functions.' );
|
||||
}
|
||||
|
||||
public function execute() {
|
||||
global $wgUseSquid, $wgSquidServers;
|
||||
if ( !$wgUseSquid ) {
|
||||
$this->fatalError( "Squid purge benchmark doesn't do much without squid support on." );
|
||||
global $wgUseCdn, $wgCdnServers;
|
||||
|
||||
if ( !$wgUseCdn ) {
|
||||
$this->error( "CDN purge benchmark doesn't do much without CDN support on." );
|
||||
} else {
|
||||
$this->output( "There are " . count( $wgSquidServers ) . " defined squid servers:\n" );
|
||||
$this->output( "There are " . count( $wgCdnServers ) . " defined CDN servers:\n" );
|
||||
if ( $this->hasOption( 'count' ) ) {
|
||||
$lengths = [ intval( $this->getOption( 'count' ) ) ];
|
||||
} else {
|
||||
|
|
@ -47,7 +48,7 @@ class BenchmarkPurge extends Benchmarker {
|
|||
}
|
||||
foreach ( $lengths as $length ) {
|
||||
$urls = $this->randomUrlList( $length );
|
||||
$trial = $this->benchSquid( $urls );
|
||||
$trial = $this->benchCdn( $urls );
|
||||
$this->output( $trial . "\n" );
|
||||
}
|
||||
}
|
||||
|
|
@ -55,12 +56,12 @@ class BenchmarkPurge extends Benchmarker {
|
|||
|
||||
/**
|
||||
* Run a bunch of URLs through CdnCacheUpdate::purge()
|
||||
* to benchmark Squid response times.
|
||||
* to benchmark CDN response times.
|
||||
* @param array $urls A bunch of URLs to purge
|
||||
* @param int $trials How many times to run the test?
|
||||
* @return string
|
||||
*/
|
||||
private function benchSquid( $urls, $trials = 1 ) {
|
||||
private function benchCdn( $urls, $trials = 1 ) {
|
||||
$start = microtime( true );
|
||||
for ( $i = 0; $i < $trials; $i++ ) {
|
||||
CdnCacheUpdate::purge( $urls );
|
||||
|
|
|
|||
|
|
@ -136,9 +136,9 @@ class PurgeChangedPages extends Maintenance {
|
|||
}
|
||||
}
|
||||
|
||||
// Send batch of purge requests out to squids
|
||||
$squid = new CdnCacheUpdate( $urls, count( $urls ) );
|
||||
$squid->doUpdate();
|
||||
// Send batch of purge requests out to CDN servers
|
||||
$cdn = new CdnCacheUpdate( $urls, count( $urls ) );
|
||||
$cdn->doUpdate();
|
||||
|
||||
if ( $this->hasOption( 'sleep-per-batch' ) ) {
|
||||
// sleep-per-batch is milliseconds, usleep wants micro seconds.
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
/**
|
||||
* Send purge requests for listed pages to squid
|
||||
* Send purge requests for listed pages to CDN
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
|
@ -24,14 +24,14 @@
|
|||
require_once __DIR__ . '/Maintenance.php';
|
||||
|
||||
/**
|
||||
* Maintenance script that sends purge requests for listed pages to squid.
|
||||
* Maintenance script that sends purge requests for listed pages to CDN.
|
||||
*
|
||||
* @ingroup Maintenance
|
||||
*/
|
||||
class PurgeList extends Maintenance {
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
$this->addDescription( 'Send purge requests for listed pages to squid' );
|
||||
$this->addDescription( 'Send purge requests for listed pages to CDN' );
|
||||
$this->addOption( 'purge', 'Whether to update page_touched.', false, false );
|
||||
$this->addOption( 'namespace', 'Namespace number', false, true );
|
||||
$this->addOption( 'all', 'Purge all pages', false, false );
|
||||
|
|
@ -120,7 +120,7 @@ class PurgeList extends Maintenance {
|
|||
|
||||
/**
|
||||
* Helper to purge an array of $urls
|
||||
* @param array $urls List of URLS to purge from squids
|
||||
* @param array $urls List of URLS to purge from CDNs
|
||||
*/
|
||||
private function sendPurgeRequest( $urls ) {
|
||||
if ( $this->hasOption( 'delay' ) ) {
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ if ( $wgRequest->getVal( 'ctype' ) == 'application/xml' ) {
|
|||
$response = $wgRequest->response();
|
||||
$response->header( "Content-type: $ctype" );
|
||||
|
||||
// Set an Expires header so that squid can cache it for a short time
|
||||
// Set an Expires header so that CDN can cache it for a short time
|
||||
// Short enough so that the sysadmin barely notices when $wgSitename is changed
|
||||
$expiryTime = 600; # 10 minutes
|
||||
$response->header( 'Expires: ' . gmdate( 'D, d M Y H:i:s', time() + $expiryTime ) . ' GMT' );
|
||||
|
|
|
|||
|
|
@ -526,9 +526,9 @@ class OutputPageTest extends MediaWikiTestCase {
|
|||
function ( $op ) {
|
||||
$op->getContext()->setUser( $this->getTestUser()->getUser() );
|
||||
} ],
|
||||
'After Squid expiry' =>
|
||||
'After CDN expiry' =>
|
||||
[ $lastModified, $lastModified, false,
|
||||
[ 'UseSquid' => true, 'SquidMaxage' => 3599 ] ],
|
||||
[ 'UseCdn' => true, 'CdnMaxAge' => 3599 ] ],
|
||||
'Hook allows cache use' =>
|
||||
[ $lastModified + 1, $lastModified, true, [],
|
||||
function ( $op, $that ) {
|
||||
|
|
@ -2225,7 +2225,7 @@ class OutputPageTest extends MediaWikiTestCase {
|
|||
}
|
||||
|
||||
public function provideAdaptCdnTTL() {
|
||||
global $wgSquidMaxage;
|
||||
global $wgCdnMaxAge;
|
||||
$now = time();
|
||||
self::$fakeTime = $now;
|
||||
return [
|
||||
|
|
@ -2234,7 +2234,7 @@ class OutputPageTest extends MediaWikiTestCase {
|
|||
'Five minutes from now' => [ [ $now + 300 ], IExpiringStore::TTL_MINUTE ],
|
||||
'Five minutes ago, initial maxage four minutes' =>
|
||||
[ [ $now - 300 ], 270, [ 'initialMaxage' => 240 ] ],
|
||||
'A very long time ago' => [ [ $now - 1000000000 ], $wgSquidMaxage ],
|
||||
'A very long time ago' => [ [ $now - 1000000000 ], $wgCdnMaxAge ],
|
||||
'Initial maxage zero' => [ [ $now - 300 ], 270, [ 'initialMaxage' => 0 ] ],
|
||||
|
||||
'false' => [ [ false ], IExpiringStore::TTL_MINUTE ],
|
||||
|
|
|
|||
|
|
@ -391,7 +391,7 @@ class WebRequestTest extends MediaWikiTestCase {
|
|||
* @dataProvider provideGetIP
|
||||
* @covers WebRequest::getIP
|
||||
*/
|
||||
public function testGetIP( $expected, $input, $squid, $xffList, $private, $description ) {
|
||||
public function testGetIP( $expected, $input, $cdn, $xffList, $private, $description ) {
|
||||
$this->setServerVars( $input );
|
||||
$this->setMwGlobals( [
|
||||
'wgUsePrivateIPs' => $private,
|
||||
|
|
@ -405,7 +405,7 @@ class WebRequestTest extends MediaWikiTestCase {
|
|||
]
|
||||
] );
|
||||
|
||||
$this->setService( 'ProxyLookup', new ProxyLookup( [], $squid ) );
|
||||
$this->setService( 'ProxyLookup', new ProxyLookup( [], $cdn ) );
|
||||
|
||||
$request = new WebRequest();
|
||||
$result = $request->getIP();
|
||||
|
|
@ -587,8 +587,8 @@ class WebRequestTest extends MediaWikiTestCase {
|
|||
public function testGetIpLackOfRemoteAddrThrowAnException() {
|
||||
// ensure that local install state doesn't interfere with test
|
||||
$this->setMwGlobals( [
|
||||
'wgSquidServersNoPurge' => [],
|
||||
'wgSquidServers' => [],
|
||||
'wgCdnServers' => [],
|
||||
'wgCdnServersNoPurge' => [],
|
||||
'wgUsePrivateIPs' => false,
|
||||
'wgHooks' => [],
|
||||
] );
|
||||
|
|
|
|||
|
|
@ -490,7 +490,7 @@ class ApiMainTest extends ApiTestCase {
|
|||
* @param int $status Expected response status
|
||||
* @param array $options Array of options:
|
||||
* post => true Request is a POST
|
||||
* cdn => true CDN is enabled ($wgUseSquid)
|
||||
* cdn => true CDN is enabled ($wgUseCdn)
|
||||
*/
|
||||
public function testCheckConditionalRequestHeaders(
|
||||
$headers, $conditions, $status, $options = []
|
||||
|
|
@ -508,7 +508,7 @@ class ApiMainTest extends ApiTestCase {
|
|||
$priv->mInternalMode = false;
|
||||
|
||||
if ( !empty( $options['cdn'] ) ) {
|
||||
$this->setMwGlobals( 'wgUseSquid', true );
|
||||
$this->setMwGlobals( 'wgUseCdn', true );
|
||||
}
|
||||
|
||||
// Can't do this in TestSetup.php because Setup.php will override it
|
||||
|
|
@ -531,7 +531,7 @@ class ApiMainTest extends ApiTestCase {
|
|||
}
|
||||
|
||||
public static function provideCheckConditionalRequestHeaders() {
|
||||
global $wgSquidMaxage;
|
||||
global $wgCdnMaxAge;
|
||||
$now = time();
|
||||
|
||||
return [
|
||||
|
|
@ -614,15 +614,15 @@ class ApiMainTest extends ApiTestCase {
|
|||
[ [ 'If-Modified-Since' => 'a potato' ],
|
||||
[ 'last-modified' => wfTimestamp( TS_MW, $now - 1 ) ], 200 ],
|
||||
|
||||
// Anything before $wgSquidMaxage seconds ago should be considered
|
||||
// Anything before $wgCdnMaxAge seconds ago should be considered
|
||||
// expired.
|
||||
'If-Modified-Since with CDN post-expiry' =>
|
||||
[ [ 'If-Modified-Since' => wfTimestamp( TS_RFC2822, $now - $wgSquidMaxage * 2 ) ],
|
||||
[ 'last-modified' => wfTimestamp( TS_MW, $now - $wgSquidMaxage * 3 ) ],
|
||||
[ [ 'If-Modified-Since' => wfTimestamp( TS_RFC2822, $now - $wgCdnMaxAge * 2 ) ],
|
||||
[ 'last-modified' => wfTimestamp( TS_MW, $now - $wgCdnMaxAge * 3 ) ],
|
||||
200, [ 'cdn' => true ] ],
|
||||
'If-Modified-Since with CDN pre-expiry' =>
|
||||
[ [ 'If-Modified-Since' => wfTimestamp( TS_RFC2822, $now - $wgSquidMaxage / 2 ) ],
|
||||
[ 'last-modified' => wfTimestamp( TS_MW, $now - $wgSquidMaxage * 3 ) ],
|
||||
[ [ 'If-Modified-Since' => wfTimestamp( TS_RFC2822, $now - $wgCdnMaxAge / 2 ) ],
|
||||
[ 'last-modified' => wfTimestamp( TS_MW, $now - $wgCdnMaxAge * 3 ) ],
|
||||
304, [ 'cdn' => true ] ],
|
||||
];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -272,7 +272,7 @@ function wfStreamThumb( array $params ) {
|
|||
|
||||
// For 404 handled thumbnails, we only use the base name of the URI
|
||||
// for the thumb params and the parent directory for the source file name.
|
||||
// Check that the zone relative path matches up so squid caches won't pick
|
||||
// Check that the zone relative path matches up so CDN caches won't pick
|
||||
// up thumbs that would not be purged on source file deletion (T36231).
|
||||
if ( $rel404 !== null ) { // thumbnail was handled via 404
|
||||
if ( rawurldecode( $rel404 ) === $img->getThumbRel( $thumbName ) ) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue