From 3d3d21174942cc359ddf33b9ccc7ed99a5a3daaa 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 f4e8176f..c31d660e 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') );