84 $this->mCacheDuration =
null;
86 $this->mConfig = $config ?: MediaWikiServices::getInstance()->getMainConfig();
88 $this->mDisabled =
false;
90 $this->mResponseCode = 200;
91 $this->mLastModified =
false;
92 $this->mContentType =
'application/x-wiki';
112 $this->mVary =
$vary;
120 $this->mResponseCode =
$code;
128 $this->mContentType =
$type;
135 $this->mDisabled =
true;
143 if ( !$this->mDisabled && $text ) {
144 $this->mText .= $text;
152 if ( !$this->mDisabled ) {
161 if ( $this->mResponseCode ) {
170 header(
"Content-Type: " . $this->mContentType );
172 if ( $this->mLastModified ) {
173 header(
"Last-Modified: " . $this->mLastModified );
175 header(
"Last-Modified: " .
gmdate(
"D, d M Y H:i:s" ) .
" GMT" );
178 if ( $this->mCacheDuration ) {
179 # If CDN caches are configured, tell them to cache the response,
180 # and tell the client to always check with the CDN. Otherwise,
181 # tell the client to use a cached copy, without a way to purge it.
183 if ( $this->mConfig->get(
'UseSquid' ) ) {
184 # Expect explicit purge of the proxy cache, but require end user agents
185 # to revalidate against the proxy on each visit.
186 # Surrogate-Control controls our CDN, Cache-Control downstream caches
188 if ( $this->mConfig->get(
'UseESI' ) ) {
190 header(
'Surrogate-Control: max-age=' . $this->mCacheDuration .
', content="ESI/1.0"' );
191 header(
'Cache-Control: s-maxage=0, must-revalidate, max-age=0' );
193 header(
'Cache-Control: s-maxage=' . $this->mCacheDuration .
', must-revalidate, max-age=0' );
197 # Let the client do the caching. Cache is not purged.
198 header(
"Expires: " .
gmdate(
"D, d M Y H:i:s", time() + $this->mCacheDuration ) .
" GMT" );
199 header(
"Cache-Control: s-maxage={$this->mCacheDuration}," .
200 "public,max-age={$this->mCacheDuration}" );
204 # always expired, always modified
205 header(
"Expires: Mon, 26 Jul 1997 05:00:00 GMT" );
206 header(
"Cache-Control: no-cache, must-revalidate" );
207 header(
"Pragma: no-cache" );
210 if ( $this->mVary ) {
211 header(
"Vary: " . $this->mVary );
225 $fname =
'AjaxResponse::checkLastModified';
227 if ( !$timestamp || $timestamp ==
'19700101000000' ) {
228 wfDebug(
"$fname: CACHE DISABLED, NO TIMESTAMP",
'private' );
233 wfDebug(
"$fname: CACHE DISABLED",
'private' );
240 if ( !empty( $_SERVER[
'HTTP_IF_MODIFIED_SINCE'] ) ) {
241 # IE sends sizes after the date like this:
242 # Wed, 20 Aug 2003 06:51:19 GMT; length=5202
243 # this breaks strtotime().
244 $modsince =
preg_replace(
'/;.*$/',
'', $_SERVER[
"HTTP_IF_MODIFIED_SINCE"] );
246 $ismodsince =
wfTimestamp( TS_MW, $modsinceTime ?: 1 );
247 wfDebug(
"$fname: -- client send If-Modified-Since: $modsince",
'private' );
248 wfDebug(
"$fname: -- we might send Last-Modified : $lastmod",
'private' );
250 if ( ( $ismodsince >= $timestamp )
251 && $wgUser->validateCache( $ismodsince ) &&
254 ini_set(
'zlib.output_compression', 0 );
259 wfDebug(
"$fname: CACHED client: $ismodsince ; user: {$wgUser->getTouched()} ; " .
260 "page: $timestamp ; site $wgCacheEpoch",
'private' );
264 wfDebug(
"$fname: READY client: $ismodsince ; user: {$wgUser->getTouched()} ; " .
265 "page: $timestamp ; site $wgCacheEpoch",
'private' );
269 wfDebug(
"$fname: client did not send If-Modified-Since header",
'private' );
285 $cache = MediaWikiServices::getInstance()->getMainWANObjectCache();
286 $mcvalue =
$cache->get( $mckey );
288 # Check to see if the value has been invalidated
289 if ( $touched <= $mcvalue[
'timestamp'] ) {
290 wfDebug(
"Got $mckey from cache" );
291 $this->mText = $mcvalue[
'value'];
295 wfDebug(
"$mckey has expired" );
308 $cache = MediaWikiServices::getInstance()->getMainWANObjectCache();
312 'value' => $this->mText
and that you know you can do these things To protect your we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights These restrictions translate to certain responsibilities for you if you distribute copies of the or if you modify it For if you distribute copies of such a whether gratis or for a you must give the recipients all the rights that you have You must make sure that receive or can get the source code And you must show them these terms so they know their rights We protect your rights with two and(2) offer you this license which gives you legal permission to copy
$wgCacheEpoch
Set this to current time to invalidate all prior cached pages.
$wgCachePages
Allow client-side caching of pages.
wfDebug( $text, $dest='all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
wfTimestampNow()
Convenience function; returns MediaWiki timestamp for the present time.
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Throws a warning that $function is deprecated.
if(defined( 'MW_SETUP_CALLBACK')) $fname
Customization point after all loading (constants, functions, classes, DefaultSettings,...
Handle responses for Ajax requests (send headers, print content, that sort of thing)
setVary( $vary)
Set the HTTP Vary header.
sendHeaders()
Construct the header and output it.
$mResponseCode
HTTP response code.
$mContentType
HTTP header Content-Type.
$mLastModified
Date for the HTTP header Last-modified.
loadFromMemcached( $mckey, $touched)
setResponseCode( $code)
Set the HTTP response code.
addText( $text)
Add content to the response.
setCacheDuration( $duration)
Set the number of seconds to get the response cached by a proxy.
__construct( $text=null, Config $config=null)
$mDisabled
Disables output.
$mText
Content of our HTTP response.
setContentType( $type)
Set the HTTP header Content-Type.
checkLastModified( $timestamp)
checkLastModified tells the client to use the client-cached response if possible.
$mCacheDuration
Number of seconds to get the response cached by a proxy.
storeInMemcached( $mckey, $expiry=86400)
static header( $code)
Output an HTTP status code header.
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that When $user is not it can be in the form of< username >< more info > e g for bot passwords intended to be added to log contexts Fields it might only if the login was with a bot password it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping see BaseTemplate::getToolbox and BaseTemplate::makeListItem for details on the format of individual items inside of this array or by returning and letting standard HTTP rendering take place modifiable or by returning false and taking over the output modifiable & $code
while(( $__line=Maintenance::readconsole()) !==false) print
Interface for configuration instances.