summaryrefslogtreecommitdiff
path: root/app.js
diff options
context:
space:
mode:
authorCheng-Han, Wu2016-04-20 18:14:28 +0800
committerCheng-Han, Wu2016-04-20 18:14:28 +0800
commit74793b516a885f21ecc1143892b6c64b916b404f (patch)
tree66cca62d8ba13ac167341f19aac0fda325f4cbef /app.js
parentb221d4ba79d3ca40ace205ba8461019f7282db53 (diff)
Updated app.js to move static file routes before use sessions which no need to have session and may gain performance
Diffstat (limited to 'app.js')
-rw-r--r--app.js10
1 files changed, 6 insertions, 4 deletions
diff --git a/app.js b/app.js
index 1dae8a41..69793813 100644
--- a/app.js
+++ b/app.js
@@ -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