From 98b236f737d4db31d663e4a5df51d33f0be67920 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 6b40f1d6..7333b187 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') );