autosave pattern

Posted by Mark on Stack Overflow See other posts from Stack Overflow or by Mark
Published on 2010-06-09T23:19:26Z Indexed on 2010/06/09 23:22 UTC
Read the original article Hit count: 170

Filed under:
|

I'm using localstorage to do gmail-style autosave on a webpage.

So I basically save every 30 seconds to local, OK.

The problem is recovery. I can't detect whether or not a user has crashed or incorrectly exited.

So let's say the user crashed and loads up the form again, I can't just continue saving and overwriting the previous autosaves. I need to restore the previous save.

But let's say the user didn't crash. He did everything correctly, but then used a different browser to edit the same file, so no new data to the previous browser's localstorage.

He then loads up the file in the previous browser. The localstorage should not be restored in that case.

Assuming there's no way to compare timestamps, how can I solve this problem?

Thanks.

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about autosave