Updated app.js to move static file routes before use sessions which no need to have session and may gain performance

This commit is contained in:
Cheng-Han, Wu 2016-04-20 18:14:28 +08:00
parent b221d4ba79
commit 74793b516a
1 changed files with 6 additions and 4 deletions

10
app.js
View File

@ -89,6 +89,11 @@ app.use(helmet.hsts({
preload: true preload: true
})); }));
// routes without sessions
// static files
app.use('/', express.static(__dirname + '/public', { maxAge: config.staticcachetime }));
app.use('/vendor/', express.static(__dirname + '/bower_components', { maxAge: config.staticcachetime }));
//session //session
app.use(session({ app.use(session({
name: config.sessionname, name: config.sessionname,
@ -145,10 +150,7 @@ passport.deserializeUser(function (id, done) {
}); });
}); });
//routes // routes need sessions
//static files
app.use('/', express.static(__dirname + '/public'));
app.use('/vendor/', express.static(__dirname + '/bower_components'));
//template files //template files
app.set('views', __dirname + '/public'); app.set('views', __dirname + '/public');
//set render engine //set render engine