views:

173

answers:

2

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 weird 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.)

A: 

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

SBUJOLD
Whoops, I should've specified that there's no sessioning involved. Editing. The reload is a good idea tho. How does Google calendar stay active?
Corey Maass
I added a 'if no activity for 20 minutes, window.location.replace...' which works great, and doesn't add to the browser history.
Corey Maass
Glad to know it helped! You could post the code to show you achieved it as an answer here to benefit others that would want to do it too.
SBUJOLD
+1  A: 

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!

Harley Green