mirror of
				https://github.com/NodeBB/NodeBB.git
				synced 2025-10-31 19:15:58 +01:00 
			
		
		
		
	setting cache headers to 0 on development mode
This commit is contained in:
		| @@ -245,7 +245,6 @@ define(function() { | |||||||
| 			readMembers = modalEl.find('#category-permissions-read'), | 			readMembers = modalEl.find('#category-permissions-read'), | ||||||
| 			writeMembers = modalEl.find('#category-permissions-write'); | 			writeMembers = modalEl.find('#category-permissions-write'); | ||||||
| 		socket.emit('api:admin.categories.getPrivilegeSettings', cid, function(err, privilegeList) { | 		socket.emit('api:admin.categories.getPrivilegeSettings', cid, function(err, privilegeList) { | ||||||
| 			console.log('privlist', privilegeList); |  | ||||||
| 			var	readLength = privilegeList['+r'].length, | 			var	readLength = privilegeList['+r'].length, | ||||||
| 				writeLength = privilegeList['+w'].length, | 				writeLength = privilegeList['+w'].length, | ||||||
| 				readFrag = document.createDocumentFragment(), | 				readFrag = document.createDocumentFragment(), | ||||||
|   | |||||||
| @@ -124,7 +124,10 @@ var fs = require('fs'), | |||||||
| 					function(next) { | 					function(next) { | ||||||
| 						// CSS Files for plugins | 						// CSS Files for plugins | ||||||
| 						if (pluginData.css && pluginData.css instanceof Array) { | 						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) { | 							_self.cssFiles = _self.cssFiles.concat(pluginData.css.map(function(file) { | ||||||
| 								return path.join('/plugins', pluginData.id, file); | 								return path.join('/plugins', pluginData.id, file); | ||||||
| 							})); | 							})); | ||||||
|   | |||||||
| @@ -31,7 +31,9 @@ var	nconf = require('nconf'), | |||||||
| 				var	fullPath = path.join(Plugins.staticDirs[req.params.id], relPath); | 				var	fullPath = path.join(Plugins.staticDirs[req.params.id], relPath); | ||||||
| 				fs.exists(fullPath, function(exists) { | 				fs.exists(fullPath, function(exists) { | ||||||
| 					if (exists) { | 					if (exists) { | ||||||
| 						res.sendfile(fullPath); | 						res.sendfile(fullPath, { | ||||||
|  | 							maxAge: app.enabled('cache') ? 5184000000 : 0 | ||||||
|  | 						}); | ||||||
| 					} else { | 					} else { | ||||||
| 						res.redirect('/404'); | 						res.redirect('/404'); | ||||||
| 					} | 					} | ||||||
|   | |||||||
| @@ -118,6 +118,11 @@ var path = require('path'), | |||||||
| 		}); | 		}); | ||||||
| 	}; | 	}; | ||||||
|  |  | ||||||
|  | 	// Cache static files on production | ||||||
|  | 	if (global.env !== 'development') { | ||||||
|  | 		app.enable('cache'); | ||||||
|  | 	} | ||||||
|  |  | ||||||
| 	// Middlewares | 	// Middlewares | ||||||
| 	app.configure(function() { | 	app.configure(function() { | ||||||
| 		async.series([ | 		async.series([ | ||||||
| @@ -181,7 +186,7 @@ var path = require('path'), | |||||||
| 								// Theme's static directory | 								// Theme's static directory | ||||||
| 								if (themeData[2]) { | 								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 | 										maxAge: app.enabled('cache') ? 5184000000 : 0 | ||||||
| 									})); | 									})); | ||||||
| 									if (process.env.NODE_ENV === 'development') { | 									if (process.env.NODE_ENV === 'development') { | ||||||
| 										winston.info('Static directory routed for theme: ' + themeData[1]); | 										winston.info('Static directory routed for theme: ' + themeData[1]); | ||||||
| @@ -190,7 +195,7 @@ var path = require('path'), | |||||||
|  |  | ||||||
| 								if (themeData[3]) { | 								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 | 										maxAge: app.enabled('cache') ? 5184000000 : 0 | ||||||
| 									})); | 									})); | ||||||
| 									if (process.env.NODE_ENV === 'development') { | 									if (process.env.NODE_ENV === 'development') { | ||||||
| 										winston.info('Custom templates directory routed for theme: ' + themeData[1]); | 										winston.info('Custom templates directory routed for theme: ' + themeData[1]); | ||||||
| @@ -252,7 +257,7 @@ var path = require('path'), | |||||||
|  |  | ||||||
| 				// Static directory /public | 				// 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 | 					maxAge: app.enabled('cache') ? 5184000000 : 0 | ||||||
| 				})); | 				})); | ||||||
|  |  | ||||||
| 				// 404 catch-all | 				// 404 catch-all | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user