diff --git a/CHANGELOG.md b/CHANGELOG.md index 8599d7b422..20ddcd65e9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Add `or` operator for Elasticsearch filters in `quickSearchByQuery` and use exists if value is `null` - @cewald (#3960) - Add unified fetch in mappingFallback for all searched entities - @gibkigonzo (#3942) - add npm-run-all for parallel build - @gibkigonzo (#3819) +- Add OutputCaching support for x-vs-store-code - @benjick (#3979) ### Fixed - Fixed Search product fails for category filter when categoryId is string - @adityasharma7 (#3929) diff --git a/core/scripts/server.ts b/core/scripts/server.ts index 361e745300..abac92483e 100755 --- a/core/scripts/server.ts +++ b/core/scripts/server.ts @@ -170,6 +170,9 @@ app.get('*', (req, res, next) => { next() } } + + const site = req.headers['x-vs-store-code'] || 'main' + const cacheKey = `page:${site}:${req.url}` const dynamicRequestHandler = renderer => { if (!renderer) { @@ -207,7 +210,7 @@ app.get('*', (req, res, next) => { output = ssr.applyAdvancedOutputProcessing(context, output, templatesCache, isProd); if (config.server.useOutputCache && cache) { cache.set( - 'page:' + req.url, + cacheKey, { headers: res.getHeaders(), body: output }, tagsArray ).catch(errorHandler) @@ -240,7 +243,7 @@ app.get('*', (req, res, next) => { const dynamicCacheHandler = () => { if (config.server.useOutputCache && cache) { cache.get( - 'page:' + req.url + cacheKey ).then(output => { if (output !== null) { if (output.headers) {