Made Content API caching configurable

refs https://github.com/TryGhost/Toolbox/issues/411

- Having hardcoded cache control values in the codebase makes it impossible to experiment with new values without a version release.
- Having all values configurable by default will allow for easier caching experiments and customizations on self-hosting instances.
This commit is contained in:
Naz 2022-09-27 17:41:56 +08:00 committed by naz
parent e45eb4d5dd
commit 874d0bf81b
2 changed files with 5 additions and 1 deletions

View File

@ -3,6 +3,7 @@ const boolParser = require('express-query-boolean');
const bodyParser = require('body-parser');
const express = require('../../../../../shared/express');
const sentry = require('../../../../../shared/sentry');
const config = require('../../../../../shared/config');
const shared = require('../../../shared');
const routes = require('./routes');
const errorHandler = require('@tryghost/mw-error-handler');
@ -22,7 +23,7 @@ module.exports = function setupApiApp() {
// Content API should allow public caching
apiApp.use(shared.middleware.cacheControl('public', {
maxAge: 0
maxAge: config.get('caching:contentAPI:maxAge')
}));
// Routing

View File

@ -131,6 +131,9 @@
},
"cors": {
"maxAge": 86400
},
"contentAPI": {
"maxAge": 0
}
},
"imageOptimization": {