mirror of
				https://github.com/NodeBB/NodeBB.git
				synced 2025-10-31 11:05:54 +01:00 
			
		
		
		
	Updated cache buster logic
Removed css and script busters in favour of a uuid/guid cache buster that is generated when the app starts. This change means that in the event your NodeBB crashes often, users will not be able to rely on their browser cache to serve an unchanged style/js file, but if that's the case, you've got bigger problems anyway. re: #3573
This commit is contained in:
		| @@ -70,8 +70,6 @@ apiController.getConfig = function(req, res, next) { | ||||
| 	config.environment = process.env.NODE_ENV; | ||||
| 	config.loggedIn = !!req.user; | ||||
| 	config['cache-buster'] = meta.config['cache-buster'] || ''; | ||||
| 	config['script-buster'] = meta.js.hash || ''; | ||||
| 	config['css-buster'] = meta.css.hash || ''; | ||||
| 	config.requireEmailConfirmation = parseInt(meta.config.requireEmailConfirmation, 10) === 1; | ||||
| 	config.topicPostSort = meta.config.topicPostSort || 'oldest_to_newest'; | ||||
| 	config.categoryTopicSort = meta.config.categoryTopicSort || 'newest_to_oldest'; | ||||
|   | ||||
| @@ -4,7 +4,8 @@ | ||||
| var winston = require('winston'), | ||||
| 	db = require('../database'), | ||||
| 	pubsub = require('../pubsub'), | ||||
| 	nconf = require('nconf'); | ||||
| 	nconf = require('nconf'), | ||||
| 	utils = require('../../public/src/utils'); | ||||
|  | ||||
| module.exports = function(Meta) { | ||||
|  | ||||
| @@ -20,6 +21,8 @@ module.exports = function(Meta) { | ||||
| 				return callback(err); | ||||
| 			} | ||||
|  | ||||
| 			config['cache-buster'] = utils.generateUUID(); | ||||
|  | ||||
| 			Meta.config = config; | ||||
| 			callback(); | ||||
| 		}); | ||||
|   | ||||
| @@ -117,24 +117,6 @@ function cacheStaticFiles(callback) { | ||||
|  | ||||
| 	app.enable('cache'); | ||||
| 	app.enable('minification'); | ||||
|  | ||||
| 	// Configure cache-buster timestamp | ||||
| 	require('child_process').exec('git describe --tags', { | ||||
| 		cwd: path.join(__dirname, '../') | ||||
| 	}, function(err, stdOut) { | ||||
| 		if (!err) { | ||||
| 			meta.config['cache-buster'] = stdOut.trim(); | ||||
| 			callback(); | ||||
| 		} else { | ||||
| 			fs.stat(path.join(__dirname, '../package.json'), function(err, stats) { | ||||
| 				if (err) { | ||||
| 					return callback(err); | ||||
| 				} | ||||
| 				meta.config['cache-buster'] = new Date(stats.mtime).getTime(); | ||||
| 				callback(); | ||||
| 			}); | ||||
| 		} | ||||
| 	}); | ||||
| } | ||||
|  | ||||
| function listen(callback) { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user