I am working on a website using Express/Mongo that will support instant messaging and push notifications using Socket.io, but I stumbled on a problem.
I had in mind creating a navigation bar similar to that found in most social media networks, with message, notifications, profile and settings icons that expand when clicked on and show relevant data to the user.
The issue is that said data needs to be up to date regardless of the route that the user request. I am wondering how to do this in a most efficient way.
An obvious solution is to handle every single route request with a call to the database and fetching all the relevant data for both messages and notifications, but this approach seems like an overkill as it would quickly overload the servers.
Am I wrong? Is this the way it's done? Is there a better way to do this?
For reference, I am attaching a link to Facebook's navigation bar for better understanding of what I'm talking about (every time you click on one of the icons in the navbar, it opens up and shows newest data regardless of the route you're on - in this case, the user clicked on the notifications icon and got back all the notifications relevant to him)
Any advice is highly appreciated!