Updated caching policy for /members/.well-known

refs https://github.com/TryGhost/Team/issues/1273

This endpoint currently only serves the members public key, which should
never change. A 24 hours cache will drastically reduce the number of
requests for the key, with little to no impact on functionality.
This commit is contained in:
Fabien "egg" O'Carroll 2022-01-14 13:40:42 +02:00
parent 5d8f491823
commit f58b5984cb

View File

@ -125,7 +125,11 @@ module.exports = function setupSiteApp(options = {}) {
siteApp.use(membersService.middleware.loadMemberSession); siteApp.use(membersService.middleware.loadMemberSession);
// /member/.well-known/* serves files (e.g. jwks.json) so it needs to be mounted before the prettyUrl mw to avoid trailing slashes // /member/.well-known/* serves files (e.g. jwks.json) so it needs to be mounted before the prettyUrl mw to avoid trailing slashes
siteApp.use('/members/.well-known', (req, res, next) => membersService.api.middleware.wellKnown(req, res, next)); siteApp.use(
'/members/.well-known',
shared.middleware.cacheControl('public', {maxAge: 60 * 60 * 24}),
(req, res, next) => membersService.api.middleware.wellKnown(req, res, next)
);
// setup middleware for internal apps // setup middleware for internal apps
// @TODO: refactor this to be a proper app middleware hook for internal apps // @TODO: refactor this to be a proper app middleware hook for internal apps