Will express-flash work with clustering?
It depends upon whether you're running clustering-compatible session middleware.
The express-flash
module uses the connect-flash
module which stores its flash message in req.session
. So, for a future request (often a redirect) to be able to access the flash message, the user's session has to be preserved.
So, if you're using a session implementation that is compatible with clustering, then express-flash
will also work with clustering. If you either don't have any session support configured or the session you're using is not clustering compatible (e.g. not based on some centralized store that all clustered processes can access), then express-flash
will not work properly.
So, it depends upon whether you're running a clustering-compatible session or not.
FYI, this doesn't really have anything to do with res.locals
as that's not where the flash data is stored (since that's a temporary object that exists only for the duration of one request). That's just the final place that the data is placed by the flash middleware when there's an incoming request and it's placed there so that templates can access it if they wish.