Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Strategies to make a web application available offline?

We're currently building a web app (Django, Ember), and we just found that most of our potential customers require sporadic offline access to the application.

What we need is not just "presenting" the app so user can navigate, caching stuff in the Manifest and so on (which I guess we will need eventually too), but we must let users actually operate as much as possible as if they were online. There will be obviously some features unavailable, but basic usage of the app should be available.

That said, I'd love to hear some thoughts on people that have confronted this scenario before. The way I see this, we need to:

1.- Either check if we're online / offline constantly or let the user specify when they're going offline (sort like Airplane mode in a smartphone).

2.- All data should be dumped into IndexedDB and from that moment on we use IndexedDB for anything related with data.

3.- When the user goes back online, a Synch process must try to dump the data from the offline user to the db online. While this might look dangerous, I don't expect a lot of users going offline at the same time while other online users are using the app, so I expect this synch process to don't become a real nightmare, also I don't expect to have race conditions.

Well, and there is obviously the option to create a Desktop standalone app...but I will try to avoid this as much as possible...

Thanks!

like image 961
AlejandroVK Avatar asked Nov 21 '15 10:11

AlejandroVK


1 Answers

  1. To check if the user is offline or online , you can use navigator.onLine but this property is not supported on all browsers. Then, if you target some of this browsers, you will have to implement an other solution with AJAX calls for example.

  2. Concerning the synchronisation, you can use available solution like CouchDB (NoSQL) on your server and use PouchDB (indexedDB) in your javascript front-end that will ease you the synchronisation process. If it doesn't meet your expectations, implement your own solution, to synchronize an indexedDB with your server database (MySQL, Postgres, MongoDB, etc...), of course, you can still use pouchDB on the front-end.

  3. Regarding performance, I think it will depend greatly on:

    • the number of servers that host your web applications
    • the number of replica of your master database
    • configuration of your servers (CPU and RAM)
like image 50
Louis Barranqueiro Avatar answered Sep 21 '22 05:09

Louis Barranqueiro