P
P
Persotr272020-11-23 04:34:10
Node.js
Persotr27, 2020-11-23 04:34:10

How to refresh or re-render a page in the browser to refresh from the server?

Hello.
There is an application - social media (network). The server side is written in Node.js.
By visiting the page of a registered user from a browser, the visitor can view his posts.
Now we need to make it so that when the user whose page the visitors are on posts a new post on his page, it is immediately rendered on the pages in the browsers of the current visitors.
What is the problem: the server cannot send a request to the client using HTTP, as far as I know. Using WebSockets is also not really an option, because if there are a million registered accounts, there will be a million socket listeners that will all work simultaneously. And yet, how to notify the client (visitor's browser) about the presence of a new post and configure the processing of this event?
I know about the option of polling the server from the browser at a certain interval for updates. Is this a good implementation? And how to design it correctly, where can I get more information about this approach? Recommend others, if any.
Thank you!

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Mors Clamor, 2020-11-23
@66demon666

In general, this is a websocket, if the network is highly loaded, then 1000 people will constantly hammer the database

V
Vladimir, 2020-11-23
@HistoryART

It does not make sense, why increase the load on the servers? The user cannot press the button to refresh the page? If you want to figure it out yourself, socket.io is the way to go.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question