Your idea is not quite right. You don’t need to make the connection yourself, but continue to use the browser’s connection method, such as http(s) ws protocol. The browser has no way to handle other communication protocols other than these categories.
So there are currently several methods of implementation.
Long polling, the page sends a request every few seconds or tens of seconds to ask the backend if there is new data, and it will be loaded if there is. The implementation method is useful for ajax or iframe.
Websocket requires the browser to support html5 and initiate a truly long connection. The server can send information to the client at any time.
Your idea is not quite right. You don’t need to make the connection yourself, but continue to use the browser’s connection method, such as http(s) ws protocol.
The browser has no way to handle other communication protocols other than these categories.
So there are currently several methods of implementation.
Long polling, the page sends a request every few seconds or tens of seconds to ask the backend if there is new data, and it will be loaded if there is. The implementation method is useful for ajax or iframe.
Websocket requires the browser to support html5 and initiate a truly long connection. The server can send information to the client at any time.
The front end can use WebStocket
ajax rotation training can do it
The backend receives, the frontend uses AJAX to request data, and then renders the page.