1
I was reading that the middleware Express Session it is not ideal to work in production, because it archives the sessions in memory. I also read that storing session data in memory is not a good practice.
So my question is: how best to use Node.JS sessions?
Use
express-session
in conjunction with any of the various session storage modules... I recommendconnect-mongo
but, you can use mysql, Dynamo, couchbase, sqlite, redis, oracle, etc...– Lauro Moraes
Storing session data in a database makes the request a little slower, doesn’t it? There is a way to store it on disk, as PHP does?
– Luiz Felipe
Yes, memory is faster. You can use a disk storage like
session-file-store
... These "disk" storages are not recommended for large applications, as the system grows it must face competition problems in the read and write system. Databases are designed to work on this aspect allowing "parallelization" of competing calls, division of "pools", etc...– Lauro Moraes
sessions, in general, are not the ideal currently pq makes your server does not comply with REST principles, specifically in not being stateless.
– guijob
@guijob ?
stateless
is precisely the "lack of session", I believe that what this user seeks is "keep the state" and so search for a way to keep data in session!– Lauro Moraes