Reputation: 1361
I'm getting bellow warning when using NODE_ENV=production
. What's the fix for this?
Warning: connection.session() MemoryStore is not
designed for a production environment, as it will leak
memory, and obviously only work within a single process.
Upvotes: 17
Views: 9229
Reputation: 9444
It could be a good idea to use Redis as your session manager. It appears as though you're using either the Express or Connect framework, and for either of them you could use an npm package connect-redis (having installed Redis). With that installed the express code would look something like this:
var express = require ( 'express' )
, RedisStore = require ( 'connect-redis' ) ( express )
, sessionStore = new RedisStore ()
, app = express.createServer ()
;
app.configure ( function () {
app.use ( express.cookieParser () );
app.use ( express.session ( {
secret: "keyboard cat", store: sessionStore, key: 'hello.sid'
} ) );
...
Upvotes: 8