0

Assuming I have users on a page of my site.

I modify a javascript file and update my server.

The problem is that users will not notice the difference until reload the page.

What to do?

Generate a token, do a comparison on all requests to detect outdated code, and reload the page to request via redirect?

And if no request is sent to the server? How to update the javascript file? Check from time to time if the version of the application has changed?

Thomas
  • 433
  • 3
  • 8
  • see this: http://stackoverflow.com/questions/4644027/auto-reload-web-page – gjpc Sep 27 '12 at 19:49
  • I think people are confusing long polling with cached javascript files. Am I correct in assuming you're asking how to ensure a user has the latest version of your code? – Mike Robinson Sep 27 '12 at 19:52
  • I control the cache by changing the filename according to content. But even so, the user will not have the updated script until reload the page with the updated reference to the javascript file. – Thomas Sep 27 '12 at 19:54
  • Do you really expect users to be in the middle of something when you update your script? And that it is unlikely that the user does something fairly often on the page to cause the page to reload in some way? – Ian Sep 27 '12 at 20:28
  • @ianpgall, if I solve a problem in the code, users with the page open for a long time does not deserve the corrected code? – Thomas Sep 27 '12 at 20:51
  • I guess I don't. When they visit your page, they are experiencing a certain version. If they want the most recent version of the page, they reload it in some way. My point is that I would expect them to do something on the page to cause them to reload it after some period of time (whether it be submitting a form, clicking a link, whatever). If they find a problem in the page, like a broken javascript function execution and something doesn't happen, then they can reload the page like a normal user would on a "broken" website. – Ian Sep 27 '12 at 21:31
  • @ianpgall, I guess you're right. If the process is not transparent to the user, it becomes unviable. Thanks for the comment. – Thomas Oct 04 '12 at 12:33

1 Answers1

1

I suggest using something Like Comet http://en.wikipedia.org/wiki/Comet_%28programming%29

This way you don't specifically have to re-load the users page.

Braunson
  • 708
  • 2
  • 14
  • 34