Missing websocket messages during full page reload

  javascript, node.js, php, websocket

I have a node.js websocket server that sends out all received messages to all connected clients (standard stuff). However, this is not a SPA app but a traditional app where the page is being fully refreshed upon each action.

The problem is that a websocket message is being sent to the client while a client is waiting for the page to reload. This causes the client to miss the websocket message because it happened in the middle of the page being reloaded before a websocket connection was established.

This wouldn’t be a problem if the application was a SPA but since it’s a traditional app this becomes a problem. I’m wondering what is the best practice to work around this problem?

Source: Ask Javascript Questions