Is there any way to detect when a user connects or disconnects from a Dash app? I’m using a server-side Redis caching (to avoid serialization, as several hundreds mb would be exchanged in some callbacks), but I can’t afford more than a few users loading data at a time because of RAM limitations. In practice, each user will a priori only load a small (but different) part of the main dataset my app allows to explore. I would like to know when I can free the memory of the Redis cache with no risk, i.e when the user disconnects.
I’m looking for a way of detecting any kind of disconnection: new URL has been entered, browser got closed, connection lost, etc. I believe I can do that with websockets, but I didn’t even know this was a thing until today, and I couldn’t find a tutorial on how to handle user connection/disconnection for a dash app. I thought session id could help, but they do not tell me when the user gets disconnected. Is there any simple way of solving my problem?
Note that although my data is read-only, I can’t work with one large global variable for the dataset as it is huge and doesn’t fit in RAM memory. I’d like to avoid working with the filesystem (hdd) as it would be too slow.