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

10
app.js
View file

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