mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-03-18 02:21:47 -05:00
Added notes for maxAge config using express.static
no issue - The milliseconds configuration here is different to "seconds" used in the max-age header value itself and other middlewares (like CORS). It's not going to be fixed upstream, so whenever this piece of code is touched again would be smart to get our own converter from seconds to milliseconds going, or some other mechanism making max-age configuration uniform across codebase
This commit is contained in:
parent
320c6e0dd3
commit
2288289ae9
2 changed files with 4 additions and 0 deletions
|
@ -32,6 +32,8 @@ function forwardToExpressStatic(req, res, next) {
|
|||
|
||||
const configMaxAge = config.get('caching:theme:maxAge');
|
||||
|
||||
// @NOTE: the maxAge config passed below are in milliseconds and the config
|
||||
// is specified in seconds. See https://github.com/expressjs/serve-static/issues/150 for more context
|
||||
express.static(themeEngine.getActive().path, {
|
||||
maxAge: (configMaxAge || configMaxAge === 0) ? configMaxAge : constants.ONE_YEAR_MS
|
||||
}
|
||||
|
|
|
@ -20,6 +20,8 @@ module.exports = function setupAdminApp() {
|
|||
// @NOTE: when we start working on HTTP/3 optimizations the immutable headers
|
||||
// produced below should be split into separate 'Cache-Control' entry.
|
||||
// For reference see: https://developer.mozilla.org/en-US/docs/Web/HTTP/Caching#validation_2
|
||||
// @NOTE: the maxAge config passed below are in milliseconds and the config
|
||||
// is specified in seconds. See https://github.com/expressjs/serve-static/issues/150 for more context
|
||||
adminApp.use('/assets', serveStatic(
|
||||
path.join(config.get('paths').adminAssets, 'assets'), {
|
||||
maxAge: (configMaxAge || configMaxAge === 0) ? configMaxAge : constants.ONE_YEAR_MS,
|
||||
|
|
Loading…
Add table
Reference in a new issue