+ All Categories
Home > Technology > OnConnectionLost: The life of an offline web application - Craft Conf 2015

OnConnectionLost: The life of an offline web application - Craft Conf 2015

Date post: 15-Jul-2015
Category:
Upload: johannes-thoenes
View: 177 times
Download: 0 times
Share this document with a friend
Popular Tags:
66
Craft Conference 2015 ON CONNECTION LOST The life of an oine web application #craftconf #oinerst @thoughtworks @sgrewenig @jthoenes
Transcript
Page 1: OnConnectionLost: The life of an offline web application - Craft Conf 2015

C r a f t C o n f e r e n c e 2 0 1 5

ON CONNECTION LOSTThe life of an offline web application

#craftconf #offlinefirst @thoughtworks

@sgrewenig @jthoenes

Page 2: OnConnectionLost: The life of an offline web application - Craft Conf 2015

OFFLINE ??!

Page 3: OnConnectionLost: The life of an offline web application - Craft Conf 2015
Page 4: OnConnectionLost: The life of an offline web application - Craft Conf 2015

WHAT ISOFFLINE ?

Page 5: OnConnectionLost: The life of an offline web application - Craft Conf 2015

STUPIDCLIENT

Page 6: OnConnectionLost: The life of an offline web application - Craft Conf 2015

MORE LOGICCLIENT-SIDE

Page 7: OnConnectionLost: The life of an offline web application - Craft Conf 2015

“INDEPENDENT”CLIENT

Page 8: OnConnectionLost: The life of an offline web application - Craft Conf 2015

WHY ?

Page 9: OnConnectionLost: The life of an offline web application - Craft Conf 2015
Page 10: OnConnectionLost: The life of an offline web application - Craft Conf 2015
Page 11: OnConnectionLost: The life of an offline web application - Craft Conf 2015

HOW ?

Page 12: OnConnectionLost: The life of an offline web application - Craft Conf 2015

CLIENT AVAILABLE OFFLINE

2 DATA AVAILABLE OFFLINE

3 DATA CHANGES OFFLINE

1

Page 13: OnConnectionLost: The life of an offline web application - Craft Conf 2015

CLIENT AVAILABLE OFFLINE1

Page 14: OnConnectionLost: The life of an offline web application - Craft Conf 2015
Page 15: OnConnectionLost: The life of an offline web application - Craft Conf 2015

APP CACHE

Page 16: OnConnectionLost: The life of an offline web application - Craft Conf 2015

APP CACHE

Page 17: OnConnectionLost: The life of an offline web application - Craft Conf 2015

INDEX.HTML

1 <!doctype html> 2 <html ... manifest="appcache.manifest"> . <!-- (...) --> 54 </html>

Page 18: OnConnectionLost: The life of an offline web application - Craft Conf 2015

APPCACHE.MANIFEST 1 CACHE MANIFEST 2 # rev 1 - 2014-10-03T13:50:18.799Z 3 4 CACHE: 5 404.html 6 favicon.ico 7 scripts/scripts.js # (...) 111 112 NETWORK: 113 * 114 115 FALLBACK: 116 / /offline.html

Page 19: OnConnectionLost: The life of an offline web application - Craft Conf 2015

APPCACHE.MANIFEST 1 CACHE MANIFEST 2 # rev 1 - 2014-10-03T13:50:18.799Z 3 4 CACHE: 5 404.html 6 favicon.ico 7 scripts/scripts.js # (...) 111 112 NETWORK: 113 * 114 115 FALLBACK: 116 / /offline.html

Page 20: OnConnectionLost: The life of an offline web application - Craft Conf 2015

APPCACHE.MANIFEST 1 CACHE MANIFEST 2 # rev 1 - 2014-10-03T13:50:18.799Z 3 4 CACHE: 5 404.html 6 favicon.ico 7 scripts/scripts.js # (...) 111 112 NETWORK: 113 * 114 115 FALLBACK: 116 / /offline.html

Page 21: OnConnectionLost: The life of an offline web application - Craft Conf 2015

APPCACHE.MANIFEST 1 CACHE MANIFEST 2 # rev 1 - 2014-10-03T13:50:18.799Z 3 4 CACHE: 5 404.html 6 favicon.ico 7 scripts/scripts.js # (...) 111 112 NETWORK: 113 * 114 115 FALLBACK: 116 / /offline.html

Page 22: OnConnectionLost: The life of an offline web application - Craft Conf 2015

APPCACHE.MANIFEST 1 CACHE MANIFEST 2 # rev 1 - 2014-10-03T13:50:18.799Z 3 4 CACHE: 5 404.html 6 favicon.ico 7 scripts/scripts.js # (...) 111 112 NETWORK: 113 * 114 115 FALLBACK: 116 / /offline.html

Page 23: OnConnectionLost: The life of an offline web application - Craft Conf 2015
Page 24: OnConnectionLost: The life of an offline web application - Craft Conf 2015

ADDITIONAL CACHE

Page 25: OnConnectionLost: The life of an offline web application - Craft Conf 2015
Page 26: OnConnectionLost: The life of an offline web application - Craft Conf 2015
Page 27: OnConnectionLost: The life of an offline web application - Craft Conf 2015

CLIENT AVAILABLE OFFLINE

2 DATA AVAILABLE OFFLINE

1

Page 28: OnConnectionLost: The life of an offline web application - Craft Conf 2015

28

//Store localStorage.town = “Antwerpen”

//Retrieve alert(localStorage.town)

WEBSTORAGEEasy to use key/value store Synchronous API

Page 29: OnConnectionLost: The life of an offline web application - Craft Conf 2015

INDEXED DB

Page 30: OnConnectionLost: The life of an offline web application - Craft Conf 2015

30

Page 31: OnConnectionLost: The life of an offline web application - Craft Conf 2015

10 var dbRequest = indexedDB.open('db_name', ‘1’);

31 var trans = database.transaction(['name'], ‘readonly'); 32 var store = trans.objectStore('name'); 33 var getRequest = store.get('4'); 34 getRequest.onsuccess = // …

42 var index = store.index('stockAmount'); 43 var cursorRequest = index.openCursor(IDBKeyRange.lower(15)); 44 cursorRequest.onsuccess = // ...

THE API

Page 32: OnConnectionLost: The life of an offline web application - Craft Conf 2015

10 var dbRequest = indexedDB.open('db_name', ‘1’);

31 var trans = database.transaction(['name'], ‘readonly'); 32 var store = trans.objectStore('name'); 33 var getRequest = store.get('4'); 34 getRequest.onsuccess = // …

42 var index = store.index('stockAmount'); 43 var cursorRequest = index.openCursor(IDBKeyRange.lower(15)); 44 cursorRequest.onsuccess = // ...

THE API

Page 33: OnConnectionLost: The life of an offline web application - Craft Conf 2015

10 var dbRequest = indexedDB.open('db_name', ‘1’);

31 var trans = database.transaction(['name'], ‘readonly'); 32 var store = trans.objectStore('name'); 33 var getRequest = store.get('4'); 34 getRequest.onsuccess = // …

42 var index = store.index('stockAmount'); 43 var cursorRequest = index.openCursor(IDBKeyRange.lower(15)); 44 cursorRequest.onsuccess = // ...

THE API

Page 34: OnConnectionLost: The life of an offline web application - Craft Conf 2015

10 var dbRequest = indexedDB.open('db_name', ‘1’);

31 var trans = database.transaction(['name'], ‘readonly'); 32 var store = trans.objectStore('name'); 33 var getRequest = store.get('4'); 34 getRequest.onsuccess = // …

42 var index = store.index('stockAmount'); 43 var cursorRequest = index.openCursor(IDBKeyRange.lower(15)); 44 cursorRequest.onsuccess = // ...

THE API

Page 35: OnConnectionLost: The life of an offline web application - Craft Conf 2015

10 var dbRequest = indexedDB.open('db_name', ‘1’);

31 var trans = database.transaction(['name'], ‘readonly'); 32 var store = trans.objectStore('name'); 33 var getRequest = store.get('4'); 34 getRequest.onsuccess = // …

42 var index = store.index('stockAmount'); 43 var cursorRequest = index.openCursor(IDBKeyRange.lower(15)); 44 cursorRequest.onsuccess = // ...

THE API

Page 36: OnConnectionLost: The life of an offline web application - Craft Conf 2015

10 var dbRequest = indexedDB.open('db_name', ‘1’);

31 var trans = database.transaction(['name'], ‘readonly'); 32 var store = trans.objectStore('name'); 33 var getRequest = store.get('4'); 34 getRequest.onsuccess = // …

42 var index = store.index('stockAmount'); 43 var cursorRequest = index.openCursor(IDBKeyRange.lower(15)); 44 cursorRequest.onsuccess = // ...

THE API

Page 37: OnConnectionLost: The life of an offline web application - Craft Conf 2015
Page 38: OnConnectionLost: The life of an offline web application - Craft Conf 2015

MIGRATIONS

Page 39: OnConnectionLost: The life of an offline web application - Craft Conf 2015

ONUPGRADE

NEEDED

Page 40: OnConnectionLost: The life of an offline web application - Craft Conf 2015

FILESYSTEM APIFILE API

Page 41: OnConnectionLost: The life of an offline web application - Craft Conf 2015

41

ADD IMAGE

filesystem:http://thedomain/persistent/xyz.jpg

Page 42: OnConnectionLost: The life of an offline web application - Craft Conf 2015

42

GET IMAGE

Page 43: OnConnectionLost: The life of an offline web application - Craft Conf 2015

IE 106.1YES YEShttp://caniuse.com/#search=fileapi

Page 44: OnConnectionLost: The life of an offline web application - Craft Conf 2015

YES NONONOhttp://caniuse.com/#search=filesystem

Page 45: OnConnectionLost: The life of an offline web application - Craft Conf 2015

CLIENT AVAILABLE OFFLINE

2 DATA AVAILABLE OFFLINE

3 DATA CHANGES OFFLINE

1

Page 46: OnConnectionLost: The life of an offline web application - Craft Conf 2015

DATA SYNCHRONISATION

Page 47: OnConnectionLost: The life of an offline web application - Craft Conf 2015

CAPTURING1 CHANGES

Page 48: OnConnectionLost: The life of an offline web application - Craft Conf 2015

QUEUE2

Page 49: OnConnectionLost: The life of an offline web application - Craft Conf 2015

PROCESSING3

Page 50: OnConnectionLost: The life of an offline web application - Craft Conf 2015

<<<<<<< HEAD

Hungarian beer is better than German beer.=======

German beer is better than Hungarian beer.>>>>>>> d237ef28dc3fab5dcccc63f580bfa7780f

Page 51: OnConnectionLost: The life of an offline web application - Craft Conf 2015

OR

Page 52: OnConnectionLost: The life of an offline web application - Craft Conf 2015

SIZE OF DATA ?

Page 53: OnConnectionLost: The life of an offline web application - Craft Conf 2015

STRUCTURE OF DATA ?

Page 54: OnConnectionLost: The life of an offline web application - Craft Conf 2015

SENSITIVE DATA ?

Page 55: OnConnectionLost: The life of an offline web application - Craft Conf 2015

POTENTIAL FOR DATA CONFLICTS ?

Page 56: OnConnectionLost: The life of an offline web application - Craft Conf 2015

BROWSER SUPPORT ?

Page 57: OnConnectionLost: The life of an offline web application - Craft Conf 2015

AMOUNT OF FUNCTIONALITY TO WORK OFFLINE ?

Page 58: OnConnectionLost: The life of an offline web application - Craft Conf 2015

58

CHALLENGE REQUIREMENTS

Page 59: OnConnectionLost: The life of an offline web application - Craft Conf 2015
Page 60: OnConnectionLost: The life of an offline web application - Craft Conf 2015

OFFLINE FIRST & EARLY

Page 61: OnConnectionLost: The life of an offline web application - Craft Conf 2015

61

EXPLORE THE POSSIBILITIES

Page 62: OnConnectionLost: The life of an offline web application - Craft Conf 2015

THANKS

@SGREWENIG

@JTHOENES

Page 63: OnConnectionLost: The life of an offline web application - Craft Conf 2015
Page 64: OnConnectionLost: The life of an offline web application - Craft Conf 2015

IE 10YESYES YEShttp://caniuse.com/#search=appcache

Page 65: OnConnectionLost: The life of an offline web application - Craft Conf 2015

IE 107.1YES YEShttp://caniuse.com/#search=indexeddb

Page 66: OnConnectionLost: The life of an offline web application - Craft Conf 2015

YESYESYES YEShttp://caniuse.com/#search=webstorage


Recommended