Denny Vrandecic has submitted this change and it was merged.
Change subject: Config setting for cache duration of entity data.
......................................................................
Config setting for cache duration of entity data.
This introduces $wgWBRepoSettings['dataSquidMaxage'] instead
of using $wgSquidMaxage to determine the cache duration for
the output of Special:EntityData. $wgWBRepoSettings['dataSquidMaxage']
defaults to $wgSquidMaxage, but should be overwritten when and where
$wgSquidMaxage is larger than a few hours, since entity data isn't
automatically purged from HTTP caches.
Change-Id: I1dabe792619c5ebd690bfe3e7bf5cd28eb5f19c9
---
M repo/config/Wikibase.default.php
M repo/includes/specials/SpecialEntityData.php
2 files changed, 18 insertions(+), 8 deletions(-)
Approvals:
Denny Vrandecic: Looks good to me, approved
jenkins-bot: Verified
diff --git a/repo/config/Wikibase.default.php b/repo/config/Wikibase.default.php
index da4768c..2bf1276 100644
--- a/repo/config/Wikibase.default.php
+++ b/repo/config/Wikibase.default.php
@@ -30,6 +30,7 @@
*/
return call_user_func( function() {
+ global $wgSquidMaxage;
$defaults = array(
@@ -72,6 +73,10 @@
// Should the page names (titles) be normalized against the
external site
'normalizeItemByTitlePageNames' => false,
+
+ // Number of seconds for which data output shall be cached.
+ // Note: keep that low, because such caches can not always be
purged easily.
+ 'dataSquidMaxage' => $wgSquidMaxage,
);
return $defaults;
diff --git a/repo/includes/specials/SpecialEntityData.php
b/repo/includes/specials/SpecialEntityData.php
index c086a97..368445b 100755
--- a/repo/includes/specials/SpecialEntityData.php
+++ b/repo/includes/specials/SpecialEntityData.php
@@ -89,6 +89,11 @@
protected $idFormatter = null;
/**
+ * @var int Cache dureation in seconds
+ */
+ protected $maxAge = 0;
+
+ /**
* @var null|array Associative array from MIME type to format name
* @note: initialized by initFormats()
*/
@@ -173,6 +178,7 @@
$this->entityLookup =
\Wikibase\StoreFactory::getStore()->getEntityLookup();
$this->dataTypeFactory = $repo->getDataTypeFactory();
$this->idFormatter = $repo->getIdFormatter();
+ $this->maxAge = \Wikibase\Settings::get( 'dataSquidMaxage' );
$this->showData( $format, $id, $revision );
}
@@ -606,25 +612,24 @@
* @param Revision $revision
*/
public function outputData( $data, $contentType, Revision $revision =
null ) {
- global $wgSquidMaxage;
-
// NOTE: similar code as in RawAction::onView, keep in sync.
$request = $this->getRequest();
$response = $request->response();
- $maxage = $request->getInt( 'maxage', $wgSquidMaxage );
- $smaxage = $request->getInt( 'smaxage', $wgSquidMaxage );
+ $maxage = $request->getInt( 'maxage', $this->maxAge );
+ $smaxage = $request->getInt( 'smaxage', $this->maxAge );
- // Sanity: 0 to 30 days. // todo: Hard maximum could be
configurable somehow.
- $maxage = max( 0, min( 60 * 60 * 24 * 30, $maxage ) );
- $smaxage = max( 0, min( 60 * 60 * 24 * 30, $smaxage ) );
+ // XXX: do we want public caching even for data from old
revisions?
+ // Sanity: 0 to 31 days. // todo: Hard maximum could be
configurable somehow.
+ $maxage = max( 0, min( 60 * 60 * 24 * 31, $maxage ) );
+ $smaxage = max( 0, min( 60 * 60 * 24 * 31, $smaxage ) );
$response->header( 'Content-Type: ' . $contentType . ';
charset=UTF-8' );
$response->header( 'Content-Length: ' . strlen( $data ) );
if ( $revision ) {
- $response->header( 'Last-Modified: ' . wfTimestamp(
TS_ISO_8601, $revision->getTimestamp() ) );
+ $response->header( 'Last-Modified: ' . wfTimestamp(
TS_RFC2822, $revision->getTimestamp() ) );
}
//Set X-Frame-Options API results (bug 39180)
--
To view, visit https://gerrit.wikimedia.org/r/64281
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I1dabe792619c5ebd690bfe3e7bf5cd28eb5f19c9
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Daniel Kinzler <[email protected]>
Gerrit-Reviewer: Aude <[email protected]>
Gerrit-Reviewer: Denny Vrandecic <[email protected]>
Gerrit-Reviewer: Tobias Gritschacher <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits