Proper configuration for Node session storage with Redis Cloud and Heroku Proper configuration for Node session storage with Redis Cloud and Heroku heroku heroku

Proper configuration for Node session storage with Redis Cloud and Heroku


Let's go by parts, as Jack the Ripper said...

It is unclear what are the correct configuration parameters to use are in the situation of using Redis Cloud and Heroku, and can't find a functioning example online.

RedisCloud on Heroku (Node Express Example) @ GitHub

Should I have resave and saveUnitialized set to true or false in the case of Redis Cloud and Heroku as the session store (using express-session)?

app.use(expressSession({resave: false, saveUninitialized: false})) reduces the number of times the session store will be accessed. This benefits hardware resources and performance (Normally is better to set them to false).

Additionally, does the cookieParser affect the session and need to be there?

Not anymore : express-session middleware, used to require cookie-parser, (but the current version of express-session reads/writes cookies directly).

And finally, should bodyParser come before or after the server.use(session)

The body-parser middleware parses the bodies of incoming HTTP requests. Populating the req.body property which is then available in your routes and middlewares. So the order doesn't influence the behaviour.

and should urlencoded extended be set to true or false?

The parsers you will need depend on the request types your server has to deal with.

The difference regarding extended: false and extended: true is already explained in this answer.