dqxyh48864 2019-07-04 20:29
浏览 77

如何在每个路径请求上保持数据最新

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)

Link: https://i2.wp.com/ikawnoclast.com/wp-content/uploads/2012/11/facebook-login-notifications-notification.png

Any advice is highly appreciated!

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 delta降尺度计算的一些细节,有偿
    • ¥15 Arduino红外遥控代码有问题
    • ¥15 数值计算离散正交多项式
    • ¥30 数值计算均差系数编程
    • ¥15 redis-full-check比较 两个集群的数据出错
    • ¥15 Matlab编程问题
    • ¥15 训练的多模态特征融合模型准确度很低怎么办
    • ¥15 kylin启动报错log4j类冲突
    • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大
    • ¥15 import arcpy出现importing _arcgisscripting 找不到相关程序