As you said, it depends on the priority of the message.
If notifications are made to the visitor performing an action, it would be easy to link the notifications based on the session.
If notifications are made by other users performing the action (for example, “John did the editing on this page. Click here to view.”), You can use AJAX with a long poll to wait for the notification.
source share