mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-03-11 02:12:21 -05:00
🎨 fix admin and theme caching issues (#8058)
refs #7812, closes #7958 - fixes boolean logic wrt to theme cache value from config - disable cache for admin assets in development - only add asset hash in production
This commit is contained in:
parent
75ba25db3f
commit
144544e83d
3 changed files with 10 additions and 3 deletions
|
@ -17,7 +17,8 @@ var debug = require('debug')('ghost:admin'),
|
|||
|
||||
module.exports = function setupAdminApp() {
|
||||
debug('Admin setup start');
|
||||
var adminApp = express();
|
||||
var adminApp = express(),
|
||||
configMaxAge;
|
||||
|
||||
// First determine whether we're serving admin or theme content
|
||||
// @TODO finish refactoring this away.
|
||||
|
@ -36,9 +37,10 @@ module.exports = function setupAdminApp() {
|
|||
|
||||
// Admin assets
|
||||
// @TODO ensure this gets a local 404 error handler
|
||||
configMaxAge = config.get('caching:admin:maxAge');
|
||||
adminApp.use('/assets', serveStatic(
|
||||
config.get('paths').clientAssets,
|
||||
{maxAge: utils.ONE_YEAR_MS, fallthrough: false}
|
||||
{maxAge: (configMaxAge || configMaxAge === 0) ? configMaxAge : utils.ONE_YEAR_MS, fallthrough: false}
|
||||
));
|
||||
|
||||
// Service Worker for offline support
|
||||
|
|
|
@ -23,6 +23,9 @@
|
|||
"caching": {
|
||||
"theme": {
|
||||
"maxAge": 0
|
||||
},
|
||||
"admin": {
|
||||
"maxAge": 0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,8 +20,10 @@ function forwardToExpressStatic(req, res, next) {
|
|||
if (!req.app.get('activeTheme')) {
|
||||
next();
|
||||
} else {
|
||||
var configMaxAge = config.get('caching:theme:maxAge');
|
||||
|
||||
express.static(path.join(config.getContentPath('themes'), req.app.get('activeTheme')),
|
||||
{maxAge: config.get('caching:theme:maxAge') || utils.ONE_YEAR_MS}
|
||||
{maxAge: (configMaxAge || configMaxAge === 0) ? configMaxAge : utils.ONE_YEAR_MS}
|
||||
)(req, res, next);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue