From bdb30976b56dc364f2294e61017d797e986ec3ce Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Tue, 26 Nov 2013 11:17:34 -0500 Subject: [PATCH] adding maxAge headers for statically served files (eep!) - issue #552 --- src/webserver.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/webserver.js b/src/webserver.js index 8b223e8f8d..7903b1b814 100644 --- a/src/webserver.js +++ b/src/webserver.js @@ -176,14 +176,18 @@ var path = require('path'), // Theme's static directory if (themeData[2]) { - app.use('/css/assets', express.static(path.join(__dirname, '../node_modules', themeData[1], themeData[2]))); + app.use('/css/assets', express.static(path.join(__dirname, '../node_modules', themeData[1], themeData[2]), { + maxAge: 5184000000 + })); if (process.env.NODE_ENV === 'development') { winston.info('Static directory routed for theme: ' + themeData[1]); } } if (themeData[3]) { - app.use('/templates', express.static(path.join(__dirname, '../node_modules', themeData[1], themeData[3]))); + app.use('/templates', express.static(path.join(__dirname, '../node_modules', themeData[1], themeData[3]), { + maxAge: 5184000000 + })); if (process.env.NODE_ENV === 'development') { winston.info('Custom templates directory routed for theme: ' + themeData[1]); } @@ -243,7 +247,9 @@ var path = require('path'), app.use(app.router); // Static directory /public - app.use(nconf.get('relative_path'), express.static(path.join(__dirname, '../', 'public'))); + app.use(nconf.get('relative_path'), express.static(path.join(__dirname, '../', 'public'), { + maxAge: 5184000000 + })); // 404 catch-all app.use(function (req, res, next) {