From db50aa64d80e7092b85aeeca89ada82cd23130fb Mon Sep 17 00:00:00 2001 From: Rishabh Date: Tue, 15 Jun 2021 10:30:00 +0530 Subject: [PATCH] Added cache invalidation for products api no refs - adding/changing products needs cache invalidation header otherwise frontend endpoints like `/members/api/site` use cached product data - adds cache invalidation for both add and edit endpoints for products --- core/server/api/canary/products.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/core/server/api/canary/products.js b/core/server/api/canary/products.js index 72574c6522..62aaaf1e3b 100644 --- a/core/server/api/canary/products.js +++ b/core/server/api/canary/products.js @@ -66,6 +66,9 @@ module.exports = { add: { statusCode: 201, + headers: { + cacheInvalidate: true + }, validation: { data: { name: {required: true} @@ -86,6 +89,7 @@ module.exports = { options: [ 'id' ], + headers: {}, validation: { options: { id: { @@ -99,6 +103,12 @@ module.exports = { frame.data, frame.options ); + + if (model.wasChanged()) { + this.headers.cacheInvalidate = true; + } else { + this.headers.cacheInvalidate = false; + } return model; } }