Skip to content

Node.js based forum software built for the modern web

setting cache headers to 0 on development mode

Julian Lam0188ea9a3b5f
diff --git a/public/src/forum/admin/categories.js b/public/src/forum/admin/categories.js
index 3f9224d626..d335c5ffde 100644
--- a/public/src/forum/admin/categories.js
+++ b/public/src/forum/admin/categories.js
@@ -245,7 +245,6 @@ define(function() {
readMembers = modalEl.find('#category-permissions-read'),
writeMembers = modalEl.find('#category-permissions-write');
socket.emit('api:admin.categories.getPrivilegeSettings', cid, function(err, privilegeList) {
- console.log('privlist', privilegeList);
var readLength = privilegeList['+r'].length,
writeLength = privilegeList['+w'].length,
readFrag = document.createDocumentFragment(),
diff --git a/src/plugins.js b/src/plugins.js
index 2a9bc7f9b2..8eea32ebab 100644
--- a/src/plugins.js
+++ b/src/plugins.js
@@ -124,7 +124,10 @@ var fs = require('fs'),
function(next) {
// CSS Files for plugins
if (pluginData.css && pluginData.css instanceof Array) {
- if (global.env === 'development') winston.info('[plugins] Found ' + pluginData.css.length + ' CSS file(s) for plugin ' + pluginData.id);
+ if (global.env === 'development') {
+ winston.info('[plugins] Found ' + pluginData.css.length + ' CSS file(s) for plugin ' + pluginData.id);
+ }
+
_self.cssFiles = _self.cssFiles.concat(pluginData.css.map(function(file) {
return path.join('/plugins', pluginData.id, file);
}));
diff --git a/src/routes/plugins.js b/src/routes/plugins.js
index 8736c51519..07e0ee408b 100644
--- a/src/routes/plugins.js
+++ b/src/routes/plugins.js
@@ -31,7 +31,9 @@ var nconf = require('nconf'),
var fullPath = path.join(Plugins.staticDirs[req.params.id], relPath);
fs.exists(fullPath, function(exists) {
if (exists) {
- res.sendfile(fullPath);
+ res.sendfile(fullPath, {
+ maxAge: app.enabled('cache') ? 5184000000 : 0
+ });
} else {
res.redirect('/404');
}
diff --git a/src/webserver.js b/src/webserver.js
index b17b628e33..d9f9bbf94f 100644
--- a/src/webserver.js
+++ b/src/webserver.js
@@ -118,6 +118,11 @@ var path = require('path'),
});
};
+ // Cache static files on production
+ if (global.env !== 'development') {
+ app.enable('cache');
+ }
+
// Middlewares
app.configure(function() {
async.series([
@@ -181,7 +186,7 @@ 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]), {
- maxAge: 5184000000
+ maxAge: app.enabled('cache') ? 5184000000 : 0
}));
if (process.env.NODE_ENV === 'development') {
winston.info('Static directory routed for theme: ' + themeData[1]);
@@ -190,7 +195,7 @@ var path = require('path'),
if (themeData[3]) {
app.use('/templates', express.static(path.join(__dirname, '../node_modules', themeData[1], themeData[3]), {
- maxAge: 5184000000
+ maxAge: app.enabled('cache') ? 5184000000 : 0
}));
if (process.env.NODE_ENV === 'development') {
winston.info('Custom templates directory routed for theme: ' + themeData[1]);
@@ -252,7 +257,7 @@ var path = require('path'),
// Static directory /public
app.use(nconf.get('relative_path'), express.static(path.join(__dirname, '../', 'public'), {
- maxAge: 5184000000
+ maxAge: app.enabled('cache') ? 5184000000 : 0
}));
// 404 catch-all