|
@ -10,6 +10,8 @@ const FOOTER_FILE = "includes/footer.html"; |
|
|
|
|
|
|
|
|
const Promise = require('promise'); |
|
|
const Promise = require('promise'); |
|
|
|
|
|
|
|
|
|
|
|
const crypto = require('crypto'); |
|
|
|
|
|
|
|
|
module.exports = |
|
|
module.exports = |
|
|
{ |
|
|
{ |
|
|
/** Appends the header html section to the result which is |
|
|
/** Appends the header html section to the result which is |
|
@ -43,7 +45,7 @@ module.exports = |
|
|
*/ |
|
|
*/ |
|
|
sendCSS: function(result, path, cache) |
|
|
sendCSS: function(result, path, cache) |
|
|
{ |
|
|
{ |
|
|
result.writeHead(200, {'Content-Type': 'text/css', 'Cache-Control': 'public, max-age=604800'}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var css = cache.get(path); |
|
|
var css = cache.get(path); |
|
|
|
|
|
|
|
@ -51,6 +53,8 @@ module.exports = |
|
|
{ |
|
|
{ |
|
|
utils.include("./" + path).then(function(content) |
|
|
utils.include("./" + path).then(function(content) |
|
|
{ |
|
|
{ |
|
|
|
|
|
var eTag = crypto.createHash('md5').update(content).digest('hex'); |
|
|
|
|
|
result.writeHead(200, {'Content-Type': 'text/css', 'Cache-Control': 'public, max-age=2678400', 'ETag': '"' + eTag + '"'}); |
|
|
result.write(content); |
|
|
result.write(content); |
|
|
result.end(); |
|
|
result.end(); |
|
|
cache.put(path, content); |
|
|
cache.put(path, content); |
|
@ -61,6 +65,8 @@ module.exports = |
|
|
} |
|
|
} |
|
|
else |
|
|
else |
|
|
{ |
|
|
{ |
|
|
|
|
|
var eTag = crypto.createHash('md5').update(css).digest('hex'); |
|
|
|
|
|
result.writeHead(200, {'Content-Type': 'text/css', 'Cache-Control': 'public, max-age=2678400', 'ETag': '"' + eTag + '"'}); |
|
|
result.write(css); |
|
|
result.write(css); |
|
|
result.end(); |
|
|
result.end(); |
|
|
} |
|
|
} |
|
|