From eea8f1d94f40f3aa39d0406982656ea1ce314cce Mon Sep 17 00:00:00 2001 From: Julian Simioni Date: Sun, 11 Mar 2018 21:26:33 -0400 Subject: [PATCH] Only call language service when language not defaulted The default language is English, which is also what is stored in Elasticsearch. Thus, if the user did not specify a language via headers or query parameter, there is no reason to call Placeholder. Some Placeholder responses for language translation can be 30KB, and all that JSON takes considerable time to parse --- routes/v1.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/routes/v1.js b/routes/v1.js index f4e8176fd..c31d660e5 100644 --- a/routes/v1.js +++ b/routes/v1.js @@ -226,6 +226,10 @@ function addRoutes(app, peliasConfig) { isAddressItParse ); + const languageWasSpecified = function(req, res) { + return !req.clean.lang.defaulted; + }; + // get language adjustments if: // - there's a response // - theres's a lang parameter in req.clean @@ -233,6 +237,7 @@ function addRoutes(app, peliasConfig) { hasResponseData, not(hasRequestErrors), isChangeLanguageEnabled, + languageWasSpecified, hasRequestParameter('lang') );