From 5d8f491823bc621514b8d6b281afead37cf2c8c3 Mon Sep 17 00:00:00 2001 From: "Fabien \"egg\" O'Carroll" Date: Fri, 14 Jan 2022 13:39:08 +0200 Subject: [PATCH] Updated caching policy for /members/api/site refs https://github.com/TryGhost/Team/issues/1240 As this endpoint is hit on every page load when Portal is enabled, it can cause a lot of traffic to Ghost. The data does not change very frequently so we've added a 30s cache policy to alleviate load on servers. --- core/server/web/members/app.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/server/web/members/app.js b/core/server/web/members/app.js index ecf2f8b4ca..9a9f4d2c04 100644 --- a/core/server/web/members/app.js +++ b/core/server/web/members/app.js @@ -38,7 +38,7 @@ module.exports = function setupMembersApp() { membersApp.get('/api/session', middleware.getIdentityToken); membersApp.get('/api/offers/:id', middleware.getOfferData); membersApp.delete('/api/session', middleware.deleteSession); - membersApp.get('/api/site', middleware.getMemberSiteData); + membersApp.get('/api/site', shared.middleware.cacheControl('public', {maxAge: 30}), middleware.getMemberSiteData); // NOTE: this is wrapped in a function to ensure we always go via the getter membersApp.post('/api/send-magic-link', bodyParser.json(), shared.middleware.brute.membersAuth, (req, res, next) => membersService.api.middleware.sendMagicLink(req, res, next));