Skip to content

Commit 74793b5

Browse files
committed
Updated app.js to move static file routes before use sessions which no need to have session and may gain performance
1 parent b221d4b commit 74793b5

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

app.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,11 @@ app.use(helmet.hsts({
8989
preload: true
9090
}));
9191

92+
// routes without sessions
93+
// static files
94+
app.use('/', express.static(__dirname + '/public', { maxAge: config.staticcachetime }));
95+
app.use('/vendor/', express.static(__dirname + '/bower_components', { maxAge: config.staticcachetime }));
96+
9297
//session
9398
app.use(session({
9499
name: config.sessionname,
@@ -145,10 +150,7 @@ passport.deserializeUser(function (id, done) {
145150
});
146151
});
147152

148-
//routes
149-
//static files
150-
app.use('/', express.static(__dirname + '/public'));
151-
app.use('/vendor/', express.static(__dirname + '/bower_components'));
153+
// routes need sessions
152154
//template files
153155
app.set('views', __dirname + '/public');
154156
//set render engine

0 commit comments

Comments
 (0)