Assume that I am a user on the page of my site.
I update this page on my server, but users will not know the difference until the user reloads the page.
How can a JavaScript function detect the difference and reload the page?
A solution can use a timer that reloads the page every second but causes too much traffic?
You are asking that the function is a server can push information like a browser.
Otherwise, you can also create an Ajax request that will test the current version of the page displayed in the browser and verify that it has not been updated on the server side or not. Once it is ascertained that the server has a new version of the page, your script can tell the user (it is bad behavior to reload without user consent).
To avoid excessive calls to the server, you should ensure that your Ajax request is only launched from time to time (2 minutes? 5 minutes? More?), And any other request currently Its going on.
No comments:
Post a Comment