Offline first, the painless way

Marcel Kalveram
Marcel KalveramWeb Developer um Hanno.co
Offline-First
The painless way
Who is this guy?
MarcelKalveram
IWorkatHanno
Iamfromgermany
ILiveinValencia/Spain
javaScript’ingsincearound2008
RemoteUXTeam
weworkwithstartups
socialbusiness
hanno.co
@wearehanno
@marcelkalveram
Do we really need offline-first?
Traveling Commuting
Roaming Internetoutage saturatednetwork
Offline first, the painless way
What does offline-first mean?
Tomanagedatainanappinsuchaway
thatwedon'tneedserveraccessinorderto
doanykindofoperation
some well-considered
s
What is this talk about?
Native
apps
Web
sites
Web apps
Look stuff upDo stuff
When does it make sense?
content-heavysites(Nativeapps)
singlepagewebapps
staticsites
real-timeapps
self-containedapps
not our business
What are the benefits?
Nodata-lossfortheuser
Offline-firstappsarefaster…
appsareusableallthetime
HOW
to do offline-first…?
Offline challenges
cachingdynamicassets
Cachingstaticassets
PrepareUIforofflinestate
xhr, remote api calls
.json, .xml, .csv
xhr, remote api calls
Caching mechanisms
staticdata dynamicdata
page assets
.html, .css, .jpg, .js, .ttf
page assets
browsercache
serviceworkers
appcache
vs.
indexedDB
webSql
webstorage
browsercache
serviceworkers
appcache
Caching mechanisms
can’t trust him-
lack of browser support-
staticdata
page assets
.html, .css, .jpg, .js, .ttf
page assets
indexedDB
webSql
webstorage
Caching mechanisms
localforage
pouchDB
}lack of browser support -
api is overly complex -
dynamicdata
xhr, remote api calls
.json, .xml, .csv
xhr, remote api calls
Challenge #1
Caching static assets
App cache
appcache
intercepts http request
manifestfile
<html manifest="my.appcache">
cache,networkandfallback user
browser
returns cached data
server
server
App cache
cache,networkandfallback
resources can be
used offline.
online whitelist substitute non-
cached resources
appcache
user
browser
app.js
image.png
font.ttf
Manifestr
js
*
cache
network
fallback
-
App cache gotchas
1.filesalwayscomefromthecache
server side generated websites
single page applications
2.onlyupdatesifmanifestfilechange
3.needtoswapthecachemanually
serverappcache
user
browser
applicationCache.swapCache();
Browser support for…appcache
10+ 4+ 3.5+4+ 2.1+ 3.2+
Browser support for…service workers
n/a n/a n/a40+ n/a n/a
Challenge #2
caching dynamic assets
Caching mechanisms
dynamicdata
xhr, remote api calls
.json, .xml, .csv
xhr, remote api calls
indexedDB
webSql
webstorage
localforage
pouchDB
}lack of browser support -
api is overly complex -
Using web storage
no online
connection required
sessionstorage or localstorage
key/value store
appcachestorage
user
browser
Using web storage APIs
currentHighscore
lastMove
levelsCompleted
1890
D4E5
12
keys values
Using web storage APIs
localStorage.setItem("lastMove", "D4E5");
localStorage.getItem("levelsCompleted");
currentHighscore
lastMove
levelsCompleted
1890
D4E5
12
Browser support for…localstorage
8+ 3.5+ 4+4+ 2.1+ 3.2+
asynchronous
Why don’t we just use…indexedDB?
webstorage indexedDB
synchronous
limited to strings supports large data sets
no indexes indexes
10mb storage 50mb storage
Browser support for…indexedDB?
*Subfeatures not supported
**buggy behavior in iOS8
10+ 10+ 7.1+23+ 4.4+ 8+* **
Browser support for… webSQL?
*is no longer being maintained
*
n/a n/a 3.1+4+ 2.1+ 3.2+
browser APIs…
localStorage
webSql
indexedDB
limited storage options
lack of browser support
overly complex api
localForage…
…limitationsoflocalStorage
helps us overcome
…browserdifferences
supports all js objects
asynchronous
indexedDB, webSQL and localstorage
loads best driver for us
json
currentHighscore
lastMove
levelsCompleted
1890
12
localForage
localForage.setItem("lastMove", incrediblyComplexJsonObject)
localForage.getItem("levelsCompleted", function(err, val) {…});
takes care of
(de-)serialization
.then(…)
supports promises
https://github.com/mozilla/localForage
What about syncing?
localstorage
indexedDB
localforage
our responsibility
What about syncing?
localstorage
indexedDB
localforage
pouchDB
our responsibility
object
pouchDB API
pdb.put(o, cb) pdb.get(id, cb)
currentHighscore
lastMove
levelsCompleted
1890
12
_id: "lastMove",
lastPos: "D4"
newPos: "E5"
"lastMove"
pouchDB sync
pdb.sync(remoteDB);
new PouchDB("http://localhost:5984/myremotedb")
https://github.com/pouchdb/pouchdb
Challenge #3
preparing our ui
yes
no
no
yes
ami
online…
doihave
updates…
syncwith
server
offline
app
store
locally
How to detect online status
1
navigator
events
2
appcache
events
3
xhr
events
Navigator events
window.addEventListener("online", function(e) {alert("online");})
online/offline
navigator.onLine
true/false
Navigator events
is always onlineworks only
in offline-modeshows online even if
connection is unreliable
Appcache events
applicationCache.addEventListener("error", function(e) { … });
checking progress
cached
error
XHR events
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function(e) {
}
if (xhr.status != 200) {
}
thereisprobablyaconnectionissue
https://github.com/HubSpot/offline
static and dynamic data
with remote server
what to take offline
if offline-first makes sense
useevents
prepareui for flawless user experience
consider
decide
to detect offline state
cache
sync
with your users
some good in the world
empathize
Do
Thanks!
hanno.co
1 von 49

Recomendados

IndexedDB - An Efficient Way to Manage Data von
IndexedDB - An Efficient Way to Manage DataIndexedDB - An Efficient Way to Manage Data
IndexedDB - An Efficient Way to Manage Datasara stanford
318 views8 Folien
RAD Model von
RAD ModelRAD Model
RAD ModelMariamKhan120
441 views11 Folien
Reactjs von
Reactjs Reactjs
Reactjs Neha Sharma
10.5K views27 Folien
MongoDB Fundamentals von
MongoDB FundamentalsMongoDB Fundamentals
MongoDB FundamentalsMongoDB
1.8K views46 Folien
Redux Toolkit - Quick Intro - 2022 von
Redux Toolkit - Quick Intro - 2022Redux Toolkit - Quick Intro - 2022
Redux Toolkit - Quick Intro - 2022Fabio Biondi
508 views45 Folien
React JS - A quick introduction tutorial von
React JS - A quick introduction tutorialReact JS - A quick introduction tutorial
React JS - A quick introduction tutorialMohammed Fazuluddin
6.5K views15 Folien

Más contenido relacionado

Was ist angesagt?

Data Replication In Cloud Computing von
Data Replication In Cloud ComputingData Replication In Cloud Computing
Data Replication In Cloud ComputingRahul Garg
3.1K views13 Folien
Low-Code App Development von
Low-Code App DevelopmentLow-Code App Development
Low-Code App DevelopmentAppian
3.4K views9 Folien
Software Quality Assurance von
Software Quality Assurance Software Quality Assurance
Software Quality Assurance ShashankBajpai24
927 views23 Folien
MongoDB Schema Design (Richard Kreuter's Mongo Berlin preso) von
MongoDB Schema Design (Richard Kreuter's Mongo Berlin preso)MongoDB Schema Design (Richard Kreuter's Mongo Berlin preso)
MongoDB Schema Design (Richard Kreuter's Mongo Berlin preso)MongoDB
10.9K views15 Folien
Maintenance for MongoDB Replica Sets von
Maintenance for MongoDB Replica SetsMaintenance for MongoDB Replica Sets
Maintenance for MongoDB Replica SetsIgor Donchovski
439 views49 Folien
Clean architecture with ddd layering in php von
Clean architecture with ddd layering in phpClean architecture with ddd layering in php
Clean architecture with ddd layering in phpLeonardo Proietti
38.9K views177 Folien

Was ist angesagt?(20)

Data Replication In Cloud Computing von Rahul Garg
Data Replication In Cloud ComputingData Replication In Cloud Computing
Data Replication In Cloud Computing
Rahul Garg3.1K views
Low-Code App Development von Appian
Low-Code App DevelopmentLow-Code App Development
Low-Code App Development
Appian3.4K views
MongoDB Schema Design (Richard Kreuter's Mongo Berlin preso) von MongoDB
MongoDB Schema Design (Richard Kreuter's Mongo Berlin preso)MongoDB Schema Design (Richard Kreuter's Mongo Berlin preso)
MongoDB Schema Design (Richard Kreuter's Mongo Berlin preso)
MongoDB10.9K views
Maintenance for MongoDB Replica Sets von Igor Donchovski
Maintenance for MongoDB Replica SetsMaintenance for MongoDB Replica Sets
Maintenance for MongoDB Replica Sets
Igor Donchovski439 views
Clean architecture with ddd layering in php von Leonardo Proietti
Clean architecture with ddd layering in phpClean architecture with ddd layering in php
Clean architecture with ddd layering in php
Leonardo Proietti38.9K views
Mobile App Development von Chris Morrell
Mobile App DevelopmentMobile App Development
Mobile App Development
Chris Morrell16.7K views
Implementing Domain-Driven Design study group - ch. 5 entities von Henry Tong
Implementing Domain-Driven Design study group - ch. 5 entitiesImplementing Domain-Driven Design study group - ch. 5 entities
Implementing Domain-Driven Design study group - ch. 5 entities
Henry Tong292 views
Solid principles, Design Patterns, and Domain Driven Design von Irwansyah Irwansyah
Solid principles, Design Patterns, and Domain Driven DesignSolid principles, Design Patterns, and Domain Driven Design
Solid principles, Design Patterns, and Domain Driven Design
Irwansyah Irwansyah2.6K views
Introduction to MongoDB von MongoDB
Introduction to MongoDBIntroduction to MongoDB
Introduction to MongoDB
MongoDB7.2K views
Refactoring PHP von Adam Culp
Refactoring PHPRefactoring PHP
Refactoring PHP
Adam Culp3.2K views
Fundamental of Node.JS - Internship Presentation - Week7 von Devang Garach
Fundamental of Node.JS - Internship Presentation - Week7Fundamental of Node.JS - Internship Presentation - Week7
Fundamental of Node.JS - Internship Presentation - Week7
Devang Garach404 views
Sql vs NoSQL von RTigger
Sql vs NoSQLSql vs NoSQL
Sql vs NoSQL
RTigger114.6K views
Mobile Application Development von jini james
Mobile Application DevelopmentMobile Application Development
Mobile Application Development
jini james47.7K views
Shift Remote FRONTEND: Micro Frontend Architecture: A Look Into the Future - ... von Shift Conference
Shift Remote FRONTEND: Micro Frontend Architecture: A Look Into the Future - ...Shift Remote FRONTEND: Micro Frontend Architecture: A Look Into the Future - ...
Shift Remote FRONTEND: Micro Frontend Architecture: A Look Into the Future - ...
Shift Conference197 views

Destacado

Offline-First Apps with PouchDB von
Offline-First Apps with PouchDB Offline-First Apps with PouchDB
Offline-First Apps with PouchDB Paula Peña (She, Her, Hers)
1.6K views50 Folien
Couch DB/PouchDB approach for hybrid mobile applications von
Couch DB/PouchDB approach for hybrid mobile applicationsCouch DB/PouchDB approach for hybrid mobile applications
Couch DB/PouchDB approach for hybrid mobile applicationsIhor Malytskyi
5.5K views45 Folien
Pouch db tdc2016 von
Pouch db tdc2016Pouch db tdc2016
Pouch db tdc2016Itacir Pompeu
456 views41 Folien
Easy offline-first mobile and desktop web apps with PouchDB von
Easy offline-first mobile and desktop web apps with PouchDBEasy offline-first mobile and desktop web apps with PouchDB
Easy offline-first mobile and desktop web apps with PouchDBRogue Wave Software
2.5K views68 Folien
Apache CouchDB von
Apache CouchDBApache CouchDB
Apache CouchDBTrinh Phuc Tho
3.1K views20 Folien
One von
OneOne
OneJaved Lashari
231 views4 Folien

Destacado(20)

Couch DB/PouchDB approach for hybrid mobile applications von Ihor Malytskyi
Couch DB/PouchDB approach for hybrid mobile applicationsCouch DB/PouchDB approach for hybrid mobile applications
Couch DB/PouchDB approach for hybrid mobile applications
Ihor Malytskyi5.5K views
Easy offline-first mobile and desktop web apps with PouchDB von Rogue Wave Software
Easy offline-first mobile and desktop web apps with PouchDBEasy offline-first mobile and desktop web apps with PouchDB
Easy offline-first mobile and desktop web apps with PouchDB
Realism, heroism, bravery, boldness or cowardice von Agha A
Realism, heroism, bravery, boldness or cowardiceRealism, heroism, bravery, boldness or cowardice
Realism, heroism, bravery, boldness or cowardice
Agha A693 views
C:\Documents And Settings\Administrator\Desktop\Why Everyone Should Learn Cpr von steidlda
C:\Documents And Settings\Administrator\Desktop\Why Everyone Should Learn CprC:\Documents And Settings\Administrator\Desktop\Why Everyone Should Learn Cpr
C:\Documents And Settings\Administrator\Desktop\Why Everyone Should Learn Cpr
steidlda436 views
Private Engineering Colleges in Gurgaon von Dronacharya
Private Engineering Colleges in GurgaonPrivate Engineering Colleges in Gurgaon
Private Engineering Colleges in Gurgaon
Dronacharya568 views
Welcome talent - create a great LinkedIn profile von LinkedIn Nordic
Welcome talent - create a great LinkedIn profile Welcome talent - create a great LinkedIn profile
Welcome talent - create a great LinkedIn profile
LinkedIn Nordic1.2K views
Search Marketing for Business to Business von BANNER
Search Marketing for Business to BusinessSearch Marketing for Business to Business
Search Marketing for Business to Business
BANNER614 views
Reality von Bob_16
RealityReality
Reality
Bob_161.4K views
美國暢銷書第一名 von honan4108
美國暢銷書第一名美國暢銷書第一名
美國暢銷書第一名
honan4108808 views
Career Guidance In Engineering - Dronacharya von Dronacharya
Career Guidance In Engineering - DronacharyaCareer Guidance In Engineering - Dronacharya
Career Guidance In Engineering - Dronacharya
Dronacharya763 views
Mamona presentation at linuxtag von keesj
Mamona presentation at linuxtagMamona presentation at linuxtag
Mamona presentation at linuxtag
keesj667 views
Using Social Media for Collaboration von mmloban
Using Social Media for CollaborationUsing Social Media for Collaboration
Using Social Media for Collaboration
mmloban684 views
Cezanne Paule von Bob_16
Cezanne PauleCezanne Paule
Cezanne Paule
Bob_16660 views

Similar a Offline first, the painless way

Bringing The Sexy Back To WebWorkers von
Bringing The Sexy Back To WebWorkersBringing The Sexy Back To WebWorkers
Bringing The Sexy Back To WebWorkersCorey Clark, Ph.D.
2.3K views27 Folien
Creating Rajanikant Powered Site von
Creating Rajanikant Powered SiteCreating Rajanikant Powered Site
Creating Rajanikant Powered Sitemarkandey
736 views47 Folien
Web performance optimization von
Web performance optimizationWeb performance optimization
Web performance optimizationKaliop-slide
1.7K views34 Folien
TorqueBox at DC:JBUG - November 2011 von
TorqueBox at DC:JBUG - November 2011TorqueBox at DC:JBUG - November 2011
TorqueBox at DC:JBUG - November 2011bobmcwhirter
767 views98 Folien
Webdevcon Keynote hh-2012-09-18 von
Webdevcon Keynote hh-2012-09-18Webdevcon Keynote hh-2012-09-18
Webdevcon Keynote hh-2012-09-18Pierre Joye
1.4K views68 Folien
Web app and more von
Web app and moreWeb app and more
Web app and morefaming su
406 views79 Folien

Similar a Offline first, the painless way(20)

Creating Rajanikant Powered Site von markandey
Creating Rajanikant Powered SiteCreating Rajanikant Powered Site
Creating Rajanikant Powered Site
markandey736 views
Web performance optimization von Kaliop-slide
Web performance optimizationWeb performance optimization
Web performance optimization
Kaliop-slide1.7K views
TorqueBox at DC:JBUG - November 2011 von bobmcwhirter
TorqueBox at DC:JBUG - November 2011TorqueBox at DC:JBUG - November 2011
TorqueBox at DC:JBUG - November 2011
bobmcwhirter767 views
Webdevcon Keynote hh-2012-09-18 von Pierre Joye
Webdevcon Keynote hh-2012-09-18Webdevcon Keynote hh-2012-09-18
Webdevcon Keynote hh-2012-09-18
Pierre Joye1.4K views
Web app and more von faming su
Web app and moreWeb app and more
Web app and more
faming su406 views
Web Apps and more von Yan Shi
Web Apps and moreWeb Apps and more
Web Apps and more
Yan Shi1K views
Why Node.js von guileen
Why Node.jsWhy Node.js
Why Node.js
guileen2.9K views
Why Nodejs Guilin Shanghai von Jackson Tian
Why Nodejs Guilin ShanghaiWhy Nodejs Guilin Shanghai
Why Nodejs Guilin Shanghai
Jackson Tian669 views
Fake it 'til you make it von Jonathan Snook
Fake it 'til you make itFake it 'til you make it
Fake it 'til you make it
Jonathan Snook45.6K views
IPhone Web Development With Grails from CodeMash 2009 von Christopher Judd
IPhone Web Development With Grails from CodeMash 2009IPhone Web Development With Grails from CodeMash 2009
IPhone Web Development With Grails from CodeMash 2009
Christopher Judd4.7K views
HTML5 - The Python Angle (PyCon Ireland 2010) von Kevin Gill
HTML5 - The Python Angle (PyCon Ireland 2010)HTML5 - The Python Angle (PyCon Ireland 2010)
HTML5 - The Python Angle (PyCon Ireland 2010)
Kevin Gill3.7K views
Os Henrikson von oscon2007
Os HenriksonOs Henrikson
Os Henrikson
oscon2007775 views
Practical WebAssembly with Apex, wasmRS, and nanobus von Jarrod Overson
Practical WebAssembly with Apex, wasmRS, and nanobusPractical WebAssembly with Apex, wasmRS, and nanobus
Practical WebAssembly with Apex, wasmRS, and nanobus
Jarrod Overson55 views
Plattformübergreifende App-Entwicklung (ein Vergleich) - MobileTechCon 2010 von Heiko Behrens
Plattformübergreifende App-Entwicklung (ein Vergleich) - MobileTechCon 2010Plattformübergreifende App-Entwicklung (ein Vergleich) - MobileTechCon 2010
Plattformübergreifende App-Entwicklung (ein Vergleich) - MobileTechCon 2010
Heiko Behrens4.8K views
JavaScript Libraries: The Big Picture von Simon Willison
JavaScript Libraries: The Big PictureJavaScript Libraries: The Big Picture
JavaScript Libraries: The Big Picture
Simon Willison4K views
Magento Imagine 2013: Fabrizio Branca - Learning To Fly: How Angry Birds Reac... von AOE
Magento Imagine 2013: Fabrizio Branca - Learning To Fly: How Angry Birds Reac...Magento Imagine 2013: Fabrizio Branca - Learning To Fly: How Angry Birds Reac...
Magento Imagine 2013: Fabrizio Branca - Learning To Fly: How Angry Birds Reac...
AOE 3.9K views

Último

Existing documentaries (1).docx von
Existing documentaries (1).docxExisting documentaries (1).docx
Existing documentaries (1).docxMollyBrown86
13 views5 Folien
Building trust in our information ecosystem: who do we trust in an emergency von
Building trust in our information ecosystem: who do we trust in an emergencyBuilding trust in our information ecosystem: who do we trust in an emergency
Building trust in our information ecosystem: who do we trust in an emergencyTina Purnat
92 views18 Folien
information von
informationinformation
informationkhelgishekhar
8 views4 Folien
Opportunities for Youth in IG - Alena Muravska RIPE NCC.pdf von
Opportunities for Youth in IG - Alena Muravska RIPE NCC.pdfOpportunities for Youth in IG - Alena Muravska RIPE NCC.pdf
Opportunities for Youth in IG - Alena Muravska RIPE NCC.pdfRIPE NCC
9 views12 Folien
UiPath Document Understanding_Day 2.pptx von
UiPath Document Understanding_Day 2.pptxUiPath Document Understanding_Day 2.pptx
UiPath Document Understanding_Day 2.pptxRohitRadhakrishnan8
292 views21 Folien
Sustainable Marketing von
Sustainable MarketingSustainable Marketing
Sustainable MarketingTheo van der Zee
10 views50 Folien

Último(20)

Existing documentaries (1).docx von MollyBrown86
Existing documentaries (1).docxExisting documentaries (1).docx
Existing documentaries (1).docx
MollyBrown8613 views
Building trust in our information ecosystem: who do we trust in an emergency von Tina Purnat
Building trust in our information ecosystem: who do we trust in an emergencyBuilding trust in our information ecosystem: who do we trust in an emergency
Building trust in our information ecosystem: who do we trust in an emergency
Tina Purnat92 views
Opportunities for Youth in IG - Alena Muravska RIPE NCC.pdf von RIPE NCC
Opportunities for Youth in IG - Alena Muravska RIPE NCC.pdfOpportunities for Youth in IG - Alena Muravska RIPE NCC.pdf
Opportunities for Youth in IG - Alena Muravska RIPE NCC.pdf
RIPE NCC9 views
IETF 118: Starlink Protocol Performance von APNIC
IETF 118: Starlink Protocol PerformanceIETF 118: Starlink Protocol Performance
IETF 118: Starlink Protocol Performance
APNIC186 views
Serverless cloud architecture patterns von Jimmy Dahlqvist
Serverless cloud architecture patternsServerless cloud architecture patterns
Serverless cloud architecture patterns
Jimmy Dahlqvist17 views
We see everywhere that many people are talking about technology.docx von ssuserc5935b
We see everywhere that many people are talking about technology.docxWe see everywhere that many people are talking about technology.docx
We see everywhere that many people are talking about technology.docx
ssuserc5935b6 views
google forms survey (1).pptx von MollyBrown86
google forms survey (1).pptxgoogle forms survey (1).pptx
google forms survey (1).pptx
MollyBrown8614 views
AI Powered event-driven translation bot von Jimmy Dahlqvist
AI Powered event-driven translation botAI Powered event-driven translation bot
AI Powered event-driven translation bot
Jimmy Dahlqvist16 views
UiPath Document Understanding_Day 3.pptx von UiPathCommunity
UiPath Document Understanding_Day 3.pptxUiPath Document Understanding_Day 3.pptx
UiPath Document Understanding_Day 3.pptx
UiPathCommunity101 views
𝐒𝐨𝐥𝐚𝐫𝐖𝐢𝐧𝐝𝐬 𝐂𝐚𝐬𝐞 𝐒𝐭𝐮𝐝𝐲 von Infosec train
𝐒𝐨𝐥𝐚𝐫𝐖𝐢𝐧𝐝𝐬 𝐂𝐚𝐬𝐞 𝐒𝐭𝐮𝐝𝐲𝐒𝐨𝐥𝐚𝐫𝐖𝐢𝐧𝐝𝐬 𝐂𝐚𝐬𝐞 𝐒𝐭𝐮𝐝𝐲
𝐒𝐨𝐥𝐚𝐫𝐖𝐢𝐧𝐝𝐬 𝐂𝐚𝐬𝐞 𝐒𝐭𝐮𝐝𝐲
Infosec train9 views
IGF UA - Dialog with I_ organisations - Alena Muavska RIPE NCC.pdf von RIPE NCC
IGF UA - Dialog with I_ organisations - Alena Muavska RIPE NCC.pdfIGF UA - Dialog with I_ organisations - Alena Muavska RIPE NCC.pdf
IGF UA - Dialog with I_ organisations - Alena Muavska RIPE NCC.pdf
RIPE NCC15 views

Offline first, the painless way