开发者

Keeping an ajax web page functioning after hours of being idle

I have a one page web app so there is no page refreshing. Sometimes I leave the page open overnight and I come back in the morning and start interacting with it again. Usually I find I have to refresh. Javascript performs incorrectly - edit-in-place loads we开发者_JAVA技巧ird data, ajax calls don't fire... It's nothing to do with the backend, it seems to just be the browser dumping it's memory, or something. There're no sessions involved.

How does Google calendar stay open for 3 days and still fire event alerts?

I have a 'keep alive' call that fires every 5 seconds, in an attempt to keep the browser on its toes, but it hasn't helped. What's the trick? IS there a way to tell the browser to hold everything in memory forever?

(I'm sure this is addressed in numerous places on the web, but I can't figure out what to search for.)


Possible things to look at:

  • Test on a couple different browsers to see if they have the same problem.
    • If they do then its almost 100% certain something in your code.
    • Otherwise its probably something with your current browser and perhaps some interaction with some portion of your code.
  • Seems trivial but a lot of people over look this in javascript, but make sure you are deleteing/freeing anything you allocate with new.
  • If you use any 3rd party libraries consider updating them or checking their forums.

Good luck!


When you refresh the page do you need to do any authentication because of a timed-out session or anything ? Because if all you really need to do is hit F5 and you're good to go, I would suggest you create an 'idle' timer in your app that does a window.reload() every hour if there is no interaction (IOW reset that timer each time there is an interaction)

Hope this helps

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜