+ 6
which is best way to keep page updated in real time ?
lately i kinda thinking about this. let's say i have a simple web that updated frequently. no session or anything fancy, just blog-like website. i normally make a client to automaticly send a request continously to update the page. but it got me thinking. isnt this will burden the server at some point ? the i get an idea, how about make the client that listen to the server, this way the server will only need to send a broadcast once its needed. but i kinda concern about the security here, and i'm not even sure if its possible. if you have different perspective or solution, i'll be glad to hear them out :)
11 Respostas
+ 6
WebSocket can do the job.
https://developer.mozilla.org/en-US/docs/Web/API/WebSockets_API/Writing_WebSocket_client_applications
Client needs open the connection, create onmessage to listen server data.
+ 4
WebSocket server setup here using Nodejs
https://flaviocopes.com/node-websockets/
+ 3
Ajax
+ 2
Interesting ~
+ 1
Interesting and practical
For the "broadcast", can the server be submitting to connected client only? And it also set an interval to test whether the client is still connected.
+ 1
thats the main problem, unlike webhook we cant test or send anything directly to client without any request. so its hard to decide which client still connected to the server
+ 1
Hm....i remember Martin has done something similar. Martin
0
Calviղ I think this is what firebase is doing, isn't it?
0
Firebase can provide WebSocket too, but we normally use it as database storage which provide real time access.
0
I will say websockets as they have less overhead and faster communication and can be preferred over http connections. More you can research how to implement when you are developing based on the scripting language that you use for frontend - Angular, React or any other.
0
Please tell me how to work Sql with php in phone