Page MenuHomePhabricator

mw.widgets.TitleWidget should cache (client-side) the getInterwikiPrefixesPromise result
Closed, ResolvedPublic8 Estimated Story Points

Description

"Requires getting the API request to set the 'this is OK to cache' headers and the JS has to be updated to set the correct parameter thingy" according to @Legoktm.

Given this widget will eventually be used on every page read (in the search box), this would otherwise be hugely expensive for clients and the API server.

Event Timeline

Anomie subscribed.

Removing MediaWiki-Action-API, since the API already supports this.

To get the API to output a public Cache-Control header, set the maxage and smaxage parameters in your query to the appropriate number of seconds and set uselang to something other than user (which is unfortunately the default, see T97096). For example, https://en.wikipedia.org/w/api.php?format=json&action=query&meta=siteinfo&siprop=interwikimap&maxage=300&smaxage=300&uselang=content.

Also, make sure your library uses a consistent parameter ordering when building the query string.

Change 327767 had a related patch set uploaded (by Legoktm):
TitleWidget: Cache siteinfo API response

https://gerrit.wikimedia.org/r/327767

Removing MediaWiki-Action-API, since the API already supports this.

To get the API to output a public Cache-Control header, set the maxage and smaxage parameters in your query to the appropriate number of seconds and set uselang to something other than user (which is unfortunately the default, see T97096). For example, https://en.wikipedia.org/w/api.php?format=json&action=query&meta=siteinfo&siprop=interwikimap&maxage=300&smaxage=300&uselang=content.

Also, make sure your library uses a consistent parameter ordering when building the query string.

That's hugely helpful, thanks! :-)

Change 327767 merged by jenkins-bot:
TitleWidget: Cache siteinfo API response

https://gerrit.wikimedia.org/r/327767