Skip to content
This repository has been archived by the owner on Aug 30, 2021. It is now read-only.

Initialize Static Routes before session initalization #1109

Closed
tmfelwu opened this issue Dec 17, 2015 · 2 comments
Closed

Initialize Static Routes before session initalization #1109

tmfelwu opened this issue Dec 17, 2015 · 2 comments

Comments

@tmfelwu
Copy link

tmfelwu commented Dec 17, 2015

There is a very good explanation for this here

Avoid Sessions for Static Resources
I learned that if you add the session middleware before your static directory, Express will generate sessions for requests on static files like stylesheets, images, and JavaScript.
If a new visitor without a session loads a page with 10 static files, the client's browser will not yet have a cookie and will send 10 cookieless requests all triggering Express to create sessions. Ouch! So that's what was happening... If you haven't done something smart to detect bots and scrapers, things can blow out pretty quickly!
Simply put your static files first, or better yet on a CDN that has nothing to do with your Node.js app and your session collection should stay much healthier

@pgrodrigues
Copy link
Contributor

I believe this was already addressed by #1093.

@tmfelwu
Copy link
Author

tmfelwu commented Dec 17, 2015

My bad I had older version of meanjs

@tmfelwu tmfelwu closed this as completed Dec 17, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants