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.
This commit is contained in:
Fabien "egg" O'Carroll 2022-01-14 13:39:08 +02:00
parent 76b33b6e77
commit 5d8f491823

View File

@ -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));