SlideShare a Scribd company logo
OFFLINE FIRST
Better UX, faster apps
Software Engineer
PhD in Computer Science
Codemotion speaker
Rollnext Co-founder
Salvatore A. Romeo
» The problem
» Our goals
» Some examples
» UX e DX
» Making an offline first app: dev techniques
» Shared Data VS User Data
» The future
Tech Webinar: Offline First: Creare un'app Phonegap che funzioni offline e si sincronizzi automaticamente
Tech Webinar: Offline First: Creare un'app Phonegap che funzioni offline e si sincronizzi automaticamente
Tech Webinar: Offline First: Creare un'app Phonegap che funzioni offline e si sincronizzi automaticamente
Something in common?
Goal
Make the user never break the experience
Some examples
Tech Webinar: Offline First: Creare un'app Phonegap che funzioni offline e si sincronizzi automaticamente
Tech Webinar: Offline First: Creare un'app Phonegap che funzioni offline e si sincronizzi automaticamente
Tech Webinar: Offline First: Creare un'app Phonegap che funzioni offline e si sincronizzi automaticamente
Tech Webinar: Offline First: Creare un'app Phonegap che funzioni offline e si sincronizzi automaticamente
UX: Why offline?
UX: Why offline?
1. Progressive enhancement
UX: Why offline?
1. Progressive enhancement
2. Fast / No lags
What about DX?
Is it really more complicated?
Making an app: a public news room
» The user can publish news with images
» The user sees the news published by all users
» The user has a private profile
» Syncing Shared data VS Syncing Private data
Making an offline app: the tools
1. The Html5 AppCache and Phonegap
2. Save the data, sync automatically: PouchDB
3. Saving images offline: imgcache.js
4. Saving Private Data: ydn-db
5. ‘Are we Online?’ check: OnlineJS
Step 1: the app must work offline
Step 1: the app must work offline
=
Step 1: the app must work offline
=
Step 1: the app must work offline
=
The HTML5 AppCache
The HTML5 AppCache
Waiting for the ServiceWorker… a javascript module:
1. Enable/Disable the offline resources
2. Specify the resources to save offline
3. Clean the manifest
The HTML5 AppCache
1. Enable/Disable the offline resources (iframe)
The HTML5 AppCache
1. Enable/Disable the offline resources (iframe)
The HTML5 AppCache
1. Enable/Disable the offline resources (server side)
The HTML5 AppCache
1. Enable/Disable the offline resources (server side)
The HTML5 AppCache
2. Specify the resources to save offline (cookies)
The HTML5 AppCache
2. Specify the resources to save offline (cookies)
The HTML5 AppCache
The HTML5 AppCache
3. Clean the manifest (iframe + cookies)
The HTML5 AppCache
3. Clean the manifest (server side)
The HTML5 AppCache
1.
2. The cookie _manifest is set with those resources
3. An iframe is set and points to the server
4. The server parsers the resources in the cookie and
returns the corresponding manifest file
5. Available as an angular service at
https://github.com/plugback/angular/blob/master/manifest
Step 2: publishing the news
Step 2: publishing the news
Before:
Step 2: publishing the news
Before:
Now:
Step 2: publishing the news
Before:
Now:
Step 2: publishing the news
Before:
Now:
PouchDB
Somewhere in your code configuration:
PouchDB
Somewhere in your code configuration:
PouchDB
Somewhere in your code configuration:
PouchDB
Somewhere in your code configuration:
API:
Step 3: reading the news
Step 3: reading the news
Step 3: reading the news
Before:
Now:
Step 3: reading the news
Before:
Now:
Step 4: saving the images
Step 4: saving the images
Step 4: saving the images
We will use imgcache.js and a directive for img tags
https://github.com/chrisben/imgcache.js
Step 4: saving the images
We will use imgcache.js and a directive for img tags
https://github.com/chrisben/imgcache.js
Step 4: saving the images
We will use imgcache.js and a directive for img tags
https://github.com/chrisben/imgcache.js
Step 4: saving the images
We will use imgcache.js and a directive for img tags
https://github.com/chrisben/imgcache.js
The cache directive
The cache directive
The cache directive
The cache directive
The cache directive
The cache directive
Step 5: user private data
Step 5: user private data
PouchDB will sync everything with everyone!
Step 5: user private data
PouchDB will sync everything with everyone!
Step 5: user private data
PouchDB will sync everything with everyone!
Step 5: user private data
PouchDB will sync everything with everyone!
Step 5: user private data
PouchDB will sync everything with everyone!
For private data we use another approach: ydn-db
https://github.com/yathit/ydn-db
Step 5: user private data
PouchDB will sync everything with everyone!
For private data we use another approach: ydn-db
https://github.com/yathit/ydn-db
API:
Step 5: user private data
Private data should be synchronized when online.
Step 5: user private data
Private data should be synchronized when online.
navigator.onLine is not trustable!
Step 5: user private data
Private data should be synchronized when online.
navigator.onLine is not trustable!
https://github.com/PixelsCommander/OnlineJS will set the variable
window.onLine to true when the user is really
online!
Step 5: user private data
Private data should be synchronized when online.
navigator.onLine is not trustable!
https://github.com/PixelsCommander/OnlineJS will set the variable
window.onLine to true when the user is really
online!
You can use it also for online only tasks (search, real
time data, chat, …)
The Future
Internet everywhere?
References
https://github.com/plugback/angular/blob/master/manifest
http://pouchdb.com/
http://www.iriscouch.com/
https://github.com/chrisben/imgcache.js
https://github.com/yathit/ydn-db
https://github.com/PixelsCommander/OnlineJS
http://www.html5rocks.com/en/features/offline
https://plus.google.com/+IlyaGrigorik/posts/WPZsWr4QGqR
http://www.theodo.fr/blog/2014/11/how-to-build-web-applications-work-offline-
pouchdb/
http://nolanlawson.com/2014/10/03/offline-first-is-people-first
http://www.lukew.com/ff/entry.asp?1902
https://github.com/pazguille/offline-first
github.com/salvatoreromeo
me@salvatoreromeo.com
@romeosalv
linkedin.com/in/salvatoreromeo
THANK YOU

More Related Content

What's hot (20)

PPTX
Real World Lessons in Progressive Web Application & Service Worker Caching
Chris Love
 
PDF
Easing offline web application development with GWT
Arnaud Tournier
 
PDF
Max Voloshin - "Organization of frontend development for products with micros...
IT Event
 
PDF
Preparing your web services for Android and your Android app for web services...
Droidcon Eastern Europe
 
PDF
Native Desktop App with Node.js Webkit (HTML, CSS & Javascript)
Eddie Lau
 
PDF
Web Development with NodeJS
Riza Fahmi
 
PPT
Going Offline with Gears And GWT
tom.peck
 
PDF
Rapid Application Development with WSO2 Platform
WSO2
 
KEY
Html 5 boot camp
Laurie Young
 
PDF
Bringing The Sexy Back To WebWorkers
Corey Clark, Ph.D.
 
PDF
Building a Multithreaded Web-Based Game Engine Using HTML5/CSS3 and JavaScrip...
Corey Clark, Ph.D.
 
PDF
Firebase slide
Apaichon Punopas
 
PDF
When Will Drupal Die? (Keynote talk)
chrisshattuck
 
PDF
Economies of Scaling Software
Joshua Long
 
PDF
Introduction to Node.js
Aaron Rosenberg
 
PPTX
Cut your hair and get an azure webjob
Mark Greenway
 
KEY
Exciting JavaScript - Part II
Eugene Lazutkin
 
PDF
Become a Better Developer with Debugging Techniques for Drupal (and more!)
Acquia
 
PDF
Meetup Performance
Greg Whalin
 
PPTX
Cut your hair and get an azure webjob
Mark Greenway
 
Real World Lessons in Progressive Web Application & Service Worker Caching
Chris Love
 
Easing offline web application development with GWT
Arnaud Tournier
 
Max Voloshin - "Organization of frontend development for products with micros...
IT Event
 
Preparing your web services for Android and your Android app for web services...
Droidcon Eastern Europe
 
Native Desktop App with Node.js Webkit (HTML, CSS & Javascript)
Eddie Lau
 
Web Development with NodeJS
Riza Fahmi
 
Going Offline with Gears And GWT
tom.peck
 
Rapid Application Development with WSO2 Platform
WSO2
 
Html 5 boot camp
Laurie Young
 
Bringing The Sexy Back To WebWorkers
Corey Clark, Ph.D.
 
Building a Multithreaded Web-Based Game Engine Using HTML5/CSS3 and JavaScrip...
Corey Clark, Ph.D.
 
Firebase slide
Apaichon Punopas
 
When Will Drupal Die? (Keynote talk)
chrisshattuck
 
Economies of Scaling Software
Joshua Long
 
Introduction to Node.js
Aaron Rosenberg
 
Cut your hair and get an azure webjob
Mark Greenway
 
Exciting JavaScript - Part II
Eugene Lazutkin
 
Become a Better Developer with Debugging Techniques for Drupal (and more!)
Acquia
 
Meetup Performance
Greg Whalin
 
Cut your hair and get an azure webjob
Mark Greenway
 

Similar to Tech Webinar: Offline First: Creare un'app Phonegap che funzioni offline e si sincronizzi automaticamente (20)

PDF
your browser, your storage
Francesco Fullone
 
PDF
Naked and afraid Offline Mobile
ColdFusionConference
 
PDF
Naked and afraid Offline mobile
devObjective
 
PPTX
Taking Web Applications Offline
Matt Casto
 
PDF
Your browser, your storage (extended version)
Francesco Fullone
 
PPTX
Dave Orchard - Offline Web Apps with HTML5
Web Directions
 
PDF
Offline strategies for HTML5 web applications - ConFoo13
Stephan Hochdörfer
 
PDF
Html5 and beyond the next generation of mobile web applications - Touch Tou...
RIA RUI Society
 
PDF
your browser, my storage
Francesco Fullone
 
PDF
Persistent mobile JavaScript
Yorick Phoenix
 
PPTX
Offline Webapps
mnitchie
 
PDF
The Hitchhikers Guide To Html5 Offline Strategies (+firefoxOS)
David Pichsenmeister
 
PPTX
Raising ux bar with offline first design
Kyrylo Reznykov
 
PDF
Offline Strategies for HTML5 Web Applications - ipc13
Stephan Hochdörfer
 
PDF
Offline strategies for HTML5 web applications - IPC12
Stephan Hochdörfer
 
PDF
Html5 storage suggestions for challenges.pptx
deepmoteria
 
PDF
Offline Strategies for HTML5 Web Applications - oscon13
Stephan Hochdörfer
 
PDF
Client-side storage
Ruben Tan
 
PPT
HTML 5 Offline Web apps
Alexandre Marreiros
 
PDF
Offline strategies for HTML5 web applications - frOSCon8
Stephan Hochdörfer
 
your browser, your storage
Francesco Fullone
 
Naked and afraid Offline Mobile
ColdFusionConference
 
Naked and afraid Offline mobile
devObjective
 
Taking Web Applications Offline
Matt Casto
 
Your browser, your storage (extended version)
Francesco Fullone
 
Dave Orchard - Offline Web Apps with HTML5
Web Directions
 
Offline strategies for HTML5 web applications - ConFoo13
Stephan Hochdörfer
 
Html5 and beyond the next generation of mobile web applications - Touch Tou...
RIA RUI Society
 
your browser, my storage
Francesco Fullone
 
Persistent mobile JavaScript
Yorick Phoenix
 
Offline Webapps
mnitchie
 
The Hitchhikers Guide To Html5 Offline Strategies (+firefoxOS)
David Pichsenmeister
 
Raising ux bar with offline first design
Kyrylo Reznykov
 
Offline Strategies for HTML5 Web Applications - ipc13
Stephan Hochdörfer
 
Offline strategies for HTML5 web applications - IPC12
Stephan Hochdörfer
 
Html5 storage suggestions for challenges.pptx
deepmoteria
 
Offline Strategies for HTML5 Web Applications - oscon13
Stephan Hochdörfer
 
Client-side storage
Ruben Tan
 
HTML 5 Offline Web apps
Alexandre Marreiros
 
Offline strategies for HTML5 web applications - frOSCon8
Stephan Hochdörfer
 
Ad

More from Codemotion (20)

PDF
Fuzz-testing: A hacker's approach to making your code more secure | Pascal Ze...
Codemotion
 
PDF
Pompili - From hero to_zero: The FatalNoise neverending story
Codemotion
 
PPTX
Pastore - Commodore 65 - La storia
Codemotion
 
PPTX
Pennisi - Essere Richard Altwasser
Codemotion
 
PPTX
Michel Schudel - Let's build a blockchain... in 40 minutes! - Codemotion Amst...
Codemotion
 
PPTX
Richard Süselbeck - Building your own ride share app - Codemotion Amsterdam 2019
Codemotion
 
PPTX
Eward Driehuis - What we learned from 20.000 attacks - Codemotion Amsterdam 2019
Codemotion
 
PPTX
Francesco Baldassarri - Deliver Data at Scale - Codemotion Amsterdam 2019 -
Codemotion
 
PDF
Martin Förtsch, Thomas Endres - Stereoscopic Style Transfer AI - Codemotion A...
Codemotion
 
PDF
Melanie Rieback, Klaus Kursawe - Blockchain Security: Melting the "Silver Bul...
Codemotion
 
PDF
Angelo van der Sijpt - How well do you know your network stack? - Codemotion ...
Codemotion
 
PDF
Lars Wolff - Performance Testing for DevOps in the Cloud - Codemotion Amsterd...
Codemotion
 
PDF
Sascha Wolter - Conversational AI Demystified - Codemotion Amsterdam 2019
Codemotion
 
PDF
Michele Tonutti - Scaling is caring - Codemotion Amsterdam 2019
Codemotion
 
PPTX
Pat Hermens - From 100 to 1,000+ deployments a day - Codemotion Amsterdam 2019
Codemotion
 
PPTX
James Birnie - Using Many Worlds of Compute Power with Quantum - Codemotion A...
Codemotion
 
PDF
Don Goodman-Wilson - Chinese food, motor scooters, and open source developmen...
Codemotion
 
PDF
Pieter Omvlee - The story behind Sketch - Codemotion Amsterdam 2019
Codemotion
 
PDF
Dave Farley - Taking Back “Software Engineering” - Codemotion Amsterdam 2019
Codemotion
 
PDF
Joshua Hoffman - Should the CTO be Coding? - Codemotion Amsterdam 2019
Codemotion
 
Fuzz-testing: A hacker's approach to making your code more secure | Pascal Ze...
Codemotion
 
Pompili - From hero to_zero: The FatalNoise neverending story
Codemotion
 
Pastore - Commodore 65 - La storia
Codemotion
 
Pennisi - Essere Richard Altwasser
Codemotion
 
Michel Schudel - Let's build a blockchain... in 40 minutes! - Codemotion Amst...
Codemotion
 
Richard Süselbeck - Building your own ride share app - Codemotion Amsterdam 2019
Codemotion
 
Eward Driehuis - What we learned from 20.000 attacks - Codemotion Amsterdam 2019
Codemotion
 
Francesco Baldassarri - Deliver Data at Scale - Codemotion Amsterdam 2019 -
Codemotion
 
Martin Förtsch, Thomas Endres - Stereoscopic Style Transfer AI - Codemotion A...
Codemotion
 
Melanie Rieback, Klaus Kursawe - Blockchain Security: Melting the "Silver Bul...
Codemotion
 
Angelo van der Sijpt - How well do you know your network stack? - Codemotion ...
Codemotion
 
Lars Wolff - Performance Testing for DevOps in the Cloud - Codemotion Amsterd...
Codemotion
 
Sascha Wolter - Conversational AI Demystified - Codemotion Amsterdam 2019
Codemotion
 
Michele Tonutti - Scaling is caring - Codemotion Amsterdam 2019
Codemotion
 
Pat Hermens - From 100 to 1,000+ deployments a day - Codemotion Amsterdam 2019
Codemotion
 
James Birnie - Using Many Worlds of Compute Power with Quantum - Codemotion A...
Codemotion
 
Don Goodman-Wilson - Chinese food, motor scooters, and open source developmen...
Codemotion
 
Pieter Omvlee - The story behind Sketch - Codemotion Amsterdam 2019
Codemotion
 
Dave Farley - Taking Back “Software Engineering” - Codemotion Amsterdam 2019
Codemotion
 
Joshua Hoffman - Should the CTO be Coding? - Codemotion Amsterdam 2019
Codemotion
 
Ad

Tech Webinar: Offline First: Creare un'app Phonegap che funzioni offline e si sincronizzi automaticamente