What is the recommended way to store data/content locally for offline use?


#1

Hi,

I plan to build a simple app that has default content but when opened it checks for a WIFI connection and if available it tries to get the latest content version based on a timestamp comparison.

Content can be videos, images, html, menu items, etc

Where should I store all this data initially so I it can be updated later?

Here are some things I would like to do:

  • on launch test if there are any new sections/pages added to the app and save the list of pages locally for later offline use
  • get the latest videos that the app should play, delete the old ones and keep the new ones(app has a video section)
  • get the latest images that the app should show(like a photo gallery), the photo gallery should be stored locally somehow

Local storage is not recommended for storing the above(specially videos/images) so what are my options? Some database on the phone, a file solution maybe a mix?

Thank you


#2

Sounds reasonable, you can use the file and sqlite Cordova plugins for that.


#3

Other option are pouchDB


http://pouchdb.com/

Or even firebase

each of these provide their own way of handling offline data, and then synching it back up again when the user is online.


#4

I am not sure firebase provides complete offline capabilities for its web library (e.g. restart app).
It seems to be only available for native iOS and Android apps.

cf : https://www.firebase.com/blog/2015-05-29-announcing-mobile-offline-support.html


#5

Firebase JS sdk has this built in automatically


#6

Other option - Couchbase mobile:

http://developer.couchbase.com/mobile/

The mobile component (Couchbase lite) is comparable to PouchDB but not based on WebSQL/IndexedDB.
(it’s providing its own DB engine, not written in Javascript but in Java/Objective-C)

The mobile DB has automatic sync with a backend Couchbase DB. Haven’t tried it out yet.

However the same thing is possible with PouchDB, it can also sync with CouchDB:

Biggest difference with Firebase would be that you need to set up the backend yourself. However I can imagine that this could be cheaper when you need to scale up.


#7

I think she just simulates offline mode: Data are cached locally and re-synchronized when back online.
What would happen if she also closes the browser simulating an app kill, and started her app again?
Data do not seem to be stored locally yet.

Or am I wrong?


#8

Thanks for the tip.

PouchDB with CouchDB looks great, I have read a lot about it.
I want to quickly release an app with high quality backend sync service, firebase seem to be the best choice even without the support of a true offline mode in AngularFire.
PouchDB also has quite a lot of issues still opened, which is cooling me down.


#9

Ahhh, alright. In that case, you can manually cache the data and store it in localstorage


#10

Or use PouchDB for manual manually caching/storing - localstorage is quite limited, and not 100% reliable according to:

What are the issues with PouchDB? If it’s not reliable enough then Couchbase mobile might be an option.
I want this functionality too so I think I’ll whip up a few proof of concepts to try the different options.