TitleWidget: Cache siteinfo API response
authorKunal Mehta <legoktm@member.fsf.org>
Fri, 16 Dec 2016 17:46:38 +0000 (09:46 -0800)
committerKunal Mehta <legoktm@member.fsf.org>
Fri, 16 Dec 2016 18:32:45 +0000 (10:32 -0800)
This information rarely changes, so cache it for a day client-side.

Bug: T153388
Change-Id: I375a17737855eaa661c85e0dde2b7e58b67bc710

resources/src/mediawiki.widgets/mw.widgets.TitleWidget.js

index 0e5e0c5..3a4581d 100644 (file)
                        cache[ key ] = api.get( {
                                action: 'query',
                                meta: 'siteinfo',
                        cache[ key ] = api.get( {
                                action: 'query',
                                meta: 'siteinfo',
-                               siprop: 'interwikimap'
+                               siprop: 'interwikimap',
+                               // Cache client-side for a day since this info is mostly static
+                               maxage: 60 * 60 * 24,
+                               smaxage: 60 * 60 * 24,
+                               // Workaround T97096 by setting uselang=content
+                               uselang: 'content'
                        } ).then( function ( data ) {
                                return $.map( data.query.interwikimap, function ( interwiki ) {
                                        return interwiki.prefix;
                        } ).then( function ( data ) {
                                return $.map( data.query.interwikimap, function ( interwiki ) {
                                        return interwiki.prefix;