mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-20 22:42:53 -05:00
🐛 Refresh assetHash on theme override (#7430)
closes #7423 - Extend our dirty theme override cache clear hack to also reset the asset hash _ This brings alpha into line with the LTS branch - This still needs a rewrite for Ghost 1.0.0 🙄
This commit is contained in:
parent
fbf25b7653
commit
264661ee09
4 changed files with 10 additions and 3 deletions
|
@ -76,6 +76,7 @@ cacheInvalidationHeader = function cacheInvalidationHeader(req, result) {
|
|||
// Special case for if we're overwriting an active theme
|
||||
// @TODO: remove this crazy DIRTY HORRIBLE HACK
|
||||
req.app.set('activeTheme', null);
|
||||
config.set('assetHash', null);
|
||||
return INVALIDATE_ALL;
|
||||
} else if (['POST', 'PUT', 'DELETE'].indexOf(method) > -1) {
|
||||
if (endpoint === 'schedules' && subdir === 'posts') {
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
var config = require('../../config'),
|
||||
utils = require('../../utils'),
|
||||
crypto = require('crypto');
|
||||
utils = require('../../utils');
|
||||
|
||||
function getAssetUrl(path, isAdmin, minify) {
|
||||
var output = '';
|
||||
|
@ -27,7 +26,7 @@ function getAssetUrl(path, isAdmin, minify) {
|
|||
|
||||
if (!path.match(/^favicon\.ico$/)) {
|
||||
if (!config.get('assetHash')) {
|
||||
config.set('assetHash', (crypto.createHash('md5').update(config.get('ghostVersion') + Date.now()).digest('hex')).substring(0, 10));
|
||||
config.set('assetHash', utils.generateAssetHash());
|
||||
}
|
||||
|
||||
output = output + '?v=' + config.get('assetHash');
|
||||
|
|
6
core/server/utils/asset-hash.js
Normal file
6
core/server/utils/asset-hash.js
Normal file
|
@ -0,0 +1,6 @@
|
|||
var crypto = require('crypto'),
|
||||
packageInfo = require('../../../package.json');
|
||||
|
||||
module.exports = function generateAssetHash() {
|
||||
return (crypto.createHash('md5').update(packageInfo.version + Date.now()).digest('hex')).substring(0, 10);
|
||||
};
|
|
@ -104,6 +104,7 @@ utils = {
|
|||
removeOpenRedirectFromUrl: require('./remove-open-redirect-from-url'),
|
||||
zipFolder: require('./zip-folder'),
|
||||
readThemes: require('./read-themes'),
|
||||
generateAssetHash: require('./asset-hash'),
|
||||
url: require('./url')
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue