Skip to content

Node.js based forum software built for the modern web

propagating hash to all workers on css compilation

Julian Lam82708d65c63c
diff --git a/loader.js b/loader.js
index a7fd488ea7..edc7f8eb09 100644
--- a/loader.js
+++ b/loader.js
@@ -81,7 +81,8 @@ Loader.addClusterEvents = function(callback) {
worker.send({
action: 'css-propagate',
cache: Loader.css.cache,
- acpCache: Loader.css.acpCache
+ acpCache: Loader.css.acpCache,
+ hash: Loader.css.hash
});
}
@@ -120,6 +121,7 @@ Loader.addClusterEvents = function(callback) {
case 'css-propagate':
Loader.css.cache = message.cache;
Loader.css.acpCache = message.acpCache;
+ Loader.css.hash = message.hash;
otherWorkers = Object.keys(cluster.workers).filter(function(worker_id) {
return parseInt(worker_id, 10) !== parseInt(worker.id, 10);
diff --git a/src/meta/css.js b/src/meta/css.js
index fb1478dc1f..9fef2e415b 100644
--- a/src/meta/css.js
+++ b/src/meta/css.js
@@ -68,7 +68,8 @@ module.exports = function(Meta) {
process.send({
action: 'css-propagate',
cache: minified[0],
- acpCache: minified[1]
+ acpCache: minified[1],
+ hash: Meta.css.hash
});
}
@@ -139,11 +140,14 @@ module.exports = function(Meta) {
Meta.css[destination] = lessOutput.css;
- // Calculate css buster
- var hasher = crypto.createHash('md5');
+ if (destination === 'cache') {
+ // Calculate css buster
+ var hasher = crypto.createHash('md5');
- hasher.update(lessOutput.css, 'utf-8');
- Meta.css.hash = hasher.digest('hex').slice(0, 8);
+ hasher.update(lessOutput.css, 'utf-8');
+ Meta.css.hash = hasher.digest('hex').slice(0, 8);
+ console.log('the hash is now', Meta.css.hash);
+ }
// Save the compiled CSS in public/ so things like nginx can serve it
if (!cluster.isWorker || process.env.cluster_setup === 'true') {