mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Math
synced 2024-11-27 17:01:07 +00:00
Send a no-cache content request on mathpurge=true
When the user specifies the mathpurge=true query parameter, the Math extension needs to prompt RESTBase to regenerate the renders for all formulae on the page and consequently issue Varnish purge requests. This behaviour is achieved by including the `Cache-Control: no-cache` header when requesting a render. Since RESTBase regenerates all of the renders when it receives the header, send it only for the first content request; if subsequent content requests are made, RESTBase will already have the new renders. Bug: T136205 Change-Id: I44482ccc1d8afdf6d40dcf8965d8debe83ef7e17
This commit is contained in:
parent
2fc8fa6ccd
commit
d722bc51f4
|
@ -81,12 +81,16 @@ class MathMathML extends MathRenderer {
|
|||
public function render( $forceReRendering = false ) {
|
||||
global $wgMathFullRestbaseURL;
|
||||
try {
|
||||
if ( $forceReRendering ) {
|
||||
$this->setPurge( true );
|
||||
}
|
||||
if ( in_array( $this->inputType, $this->restbaseInputTypes ) &&
|
||||
$this->mode == 'mathml'
|
||||
) {
|
||||
if ( !$this->rbi ) {
|
||||
$this->rbi =
|
||||
new MathRestbaseInterface( $this->getTex(), $this->getInputType() );
|
||||
$this->rbi->setPurge( $this->isPurge() );
|
||||
}
|
||||
$rbi = $this->rbi;
|
||||
if ( $rbi->getSuccess() ) {
|
||||
|
@ -99,9 +103,6 @@ class MathMathML extends MathRenderer {
|
|||
$this->changed = false;
|
||||
return $rbi->getSuccess();
|
||||
}
|
||||
if ( $forceReRendering ) {
|
||||
$this->setPurge( true );
|
||||
}
|
||||
if ( $this->renderingRequired() ) {
|
||||
return $this->doRender();
|
||||
}
|
||||
|
|
|
@ -385,6 +385,7 @@ abstract class MathRenderer {
|
|||
*/
|
||||
public function setRestbaseInterface( $param ) {
|
||||
$this->rbi = $param;
|
||||
$this->rbi->setPurge( $this->isPurge() );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -18,6 +18,8 @@ class MathRestbaseInterface {
|
|||
private $error;
|
||||
private $mathoidStyle;
|
||||
private $mml;
|
||||
/** @var boolean is there a request to purge the existing mathematical content */
|
||||
private $purge = false;
|
||||
|
||||
/**
|
||||
* MathRestbaseInterface constructor.
|
||||
|
@ -66,6 +68,18 @@ class MathRestbaseInterface {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Lets this instance know if this is a purge request. When set to true,
|
||||
* it will cause the object to issue the first content request with a
|
||||
* 'Cache-Control: no-cache' header to prompt the regeneration of the
|
||||
* renders.
|
||||
*
|
||||
* @param bool $purge whether this is a purge request
|
||||
*/
|
||||
public function setPurge( $purge = true ) {
|
||||
$this->purge = $purge;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string MathML code
|
||||
* @throws MWException
|
||||
|
@ -383,6 +397,12 @@ class MathRestbaseInterface {
|
|||
'method' => 'GET',
|
||||
'url' => $this->getUrl( "media/math/render/$type/{$this->hash}" )
|
||||
];
|
||||
if ( $this->purge ) {
|
||||
$request['headers'] = [
|
||||
'Cache-Control' => 'no-cache'
|
||||
];
|
||||
$this->purge = false;
|
||||
}
|
||||
return $request;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue