From 8b8db66dd1bb98bd0e32bf2d2d15807f0e7d1523 Mon Sep 17 00:00:00 2001 From: Sam Smith Date: Fri, 2 Sep 2016 10:31:43 +0100 Subject: [PATCH] Cache "morelike" requests for all users In order to minimize loading time of RA for as many users as possible, we need to maximize the number of users that can be served by our edge caches. Currently, if you're logged in, then the API uses your language by default and so responses are always private, i.e. they shouldn't be cached by a shared cache and can be cached by the browser. By requesting that the response be in the language of the content, the API ignores your language and responses become public, i.e. they can be cached in a shared cache and can be cached by the browser. Changes: * Add the `uselang=content` parameter to the morelike request * Add the `maxage=86400` parameter to the morelike request, allowing the browser to cache the response for 24 hours, which'll save the device even making the request Bug: T126455 Change-Id: I6216a088d865f27f7cc3725fc311191da42a27ba --- .../RelatedPagesGateway.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/resources/ext.relatedArticles.readMore.gateway/RelatedPagesGateway.js b/resources/ext.relatedArticles.readMore.gateway/RelatedPagesGateway.js index 46e77fcc..9e69cd4b 100644 --- a/resources/ext.relatedArticles.readMore.gateway/RelatedPagesGateway.js +++ b/resources/ext.relatedArticles.readMore.gateway/RelatedPagesGateway.js @@ -77,7 +77,22 @@ parameters.gsrnamespace = '0'; parameters.gsrlimit = limit; parameters.gsrqiprofile = 'classic_noboostlinks'; - parameters.smaxage = 86400; // 24 hours + + // Currently, if you're logged in, then the API uses your language by default ard so responses + // are always private i.e. they shouldn't be cached in a shared cache and can be cached by the + // browser. + // + // By make the API use the language of the content rather than that of the user, the API + // reponse is made public, i.e. they can be cached in a shared cache. + // + // See T97096 for more detail and discussion. + parameters.uselang = 'content'; + + // Instruct shared caches that the response will become stale in 24 hours. + parameters.smaxage = 86400; + + // Instruct the browser that the response will become stale in 24 hours. + parameters.maxage = 86400; } else { return $.Deferred().resolve( [] ); }