I saw a lot of sites (like facebook or stack overflow) that will update some functions as new data is created (like a new message reply).
Suppose that a new post has been added to the blog, and someone on the blog is looking at it at that moment, the idea is to automatically add a new post to the blog without updating, or be able to do something.
I was thinking of making an AJAX call every 5 seconds or so, but that would cause too many requests to the server, and I saw that the sites I mentioned (which update the content) did not create any new requests.
I am really out of ideas on how to achieve this. Is this possible with PHP and AJAX? I also heard about websockets. Any ideas? Thanks
source share