Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Dealing with Data Offline in Web Apps

Jai Santhosh
September 10, 2017

Dealing with Data Offline in Web Apps

This talk explores and help us understand how we can elevate your apps with a Service Worker and explore various options of data management when you are offline. Some suggestions include redux-offline, pouchdb, a simple IndexedDB.

The talk also addresses into how can you wire your application such that heavy offline data can be seamlessly sync-ed once the user gets online and few approaches of how to manage the behaviour of your APIs to help you with this aspect.

Jai Santhosh

September 10, 2017
Tweet

More Decks by Jai Santhosh

Other Decks in Technology

Transcript

  1. D E A L I N G W I T

    H D ATA O F F L I N E I N W E B A P P S
  2. W I T H O U T I N T

    E R N E T…
  3. L E T ’ S G E T A L

    I L S E R I O U S
  4. 3.4 billion Internet users 5.6 hours per day SOURCE: KLEINER

    PERKINS INTERNET TRENDS REPORT 2017 In India alone, 355 million users (~10%)
  5. T H I N G S A R E N

    O T I D E A L … Flaky Connections Users switch off data!
  6. S E R V I C E W O R

    K E R ! ! https://developers.google.com/web/fundamentals/getting-started/primers/service-workers
  7. A S A T H U M B R U

    L E • For URL addressable resources, Use Cache API • For everything else, use IndexedDB
  8. S E R V I C E W O R

    K E R Straightforward for Read-only offline mode What about if its write heavy?
  9. S E R V I C E W O R

    K E R C A C H E A P I Browser Browser IndexedDB Service Worker new Response( ) localForage, idb-keyval, ydn-db, etc. For URL addressable resources IndexedDB with a Promise wrapper
  10. Web App Internet W I T H S E R

    V I C E W O R K E R . . IndexedDB Service Worker
  11. Web App Internet B E T T E R I

    F… IndexedDB Service Worker
  12. P E R S I S T I N G

    D ATA S T O R E Data Model Data Store
  13. P E R S I S T I N G

    D ATA S T O R E Data Model Redux Store
  14. R E D U X O F F L I

    N E • Uses redux-persist • Persists redux store to disk on every change • Reload automatically on startup • Redux Offline creates an offline subtree • Manages an array of an Outbox
  15. R E D U X O F F L I

    N E https://github.com/jevakallio/redux-offline
  16. R E D U X O F F L I

    N E https://github.com/jevakallio/redux-offline You can have more offline strategies..
  17. P O U C H D B • Enables you

    to store data locally while offline • Synchronizes with CouchDB-like servers once online • 46kb (gzipped) • Works on all browsers and Node.js https://pouchdb.com/
  18. P O U C H D B • onChange is

    useful for better UX • Design UX for offline mode & online mode
  19. H A N D L I N G D ATA

    O F F L I N E • Data Validations • Concurrent Data Edits • Managing offline <-> online sync-ing better Always have versions for your data!!
  20. H O W M U C H C A N

    Y O U S T O R E ? https://developers.google.com/web/fundamentals/instant-and-offline/web-storage/offline-for-pwa
  21. Q U O TA M A N A G E

    M E N T A P I https://developer.mozilla.org/en-US/docs/Web/API/StorageQuota