ServerSideSkittles ServerSideSkittles - 1 month ago 11
Ajax Question

Storing data offline until online is connected

I am planning on making a Web app for feedback. However the device it will be used on isn't connected online.

The idea is to have it store any input offline until it reaches a connection. The device in question will be an ipad and the target database is mysql.

Ive seen Web storage but also wondering about offline site altogether as one could refresh the page by accident and with no connection it will fail. Ideally I will use php,mysql and html5. I was thinking originaly to store data I'm local storage then use ajax to keep pinging for a connection. I'm looking for an elegant way of doing this without suffering any data loss. Any suggestions would be greatly appreciated!

Answer

This is absolutly possible with a modern Browser. You can use Service Workers to make the Page avalible offline, with it you can load and refresh the Site offline. For Storage you can use Webstorage or IndexedDB like you already sayed. And for detecting the Internet Connection, there are already Events provided by the Browser.

This concept is called Progressive Webapps, for an example you can look at the Google IO Page of this year