SlideShare a Scribd company logo
1 of 29
HTML5 and Offline David Orchard Mobile Architect
Outline Easy stuff Web Storage App Cache Web SQL Hard stuff Naming Cache invalidation Writing Oh, and security
HTML5
Web Storage Aka HTML5 Storage SessionStorage Scoped to session No sharing across windows LocalStorage Persistent Shared across windows Size: 5M, 10M, expandable
Web storage API	 setItem(key, value) sessionStorage.setItem(key, value) sessionStorage.key=value sessionStorage[‘key’]=value getItem(key) removeItem(key) length key(index) clear
WebStorage data types String That’s it. Use JSON to serialize/deserialize structures Json.org/json2.js Careful of serializing too much
Web storage tips/references try {     return 'localStorage' in window && window['localStorage'] !== null; } catch (e) {     return false;  } } Modernizr.sessionstorage Modernizr.localstorage http://diveintohtml5.org/storage.html
HTML5 Cache Manifest Central resource for html5 caching <!DOCTYPE HTML> <html manifest=“/appcache.manifest”> <body> </body> </html> Every page in your app must refer to the manifest
Serving Cache Manifest Must be content-type text/cache-manifest Document name must end in .manifest Watch out for HTTP caching the manifest Make sure cache file gets refreshed when you refresh Can tell if clearing the cache works Or just the checking event fired (events coming up) Configure server to tell browser to not cache manifest
Cache Manifest	 CACHE MANIFEST #version 13 #equivalent to CACHE: section /index.html /wickedjslib.js /awesomestyle.css NETWORK: * FALLBACK: / /fallback.html
Browser behavior User may be offered option of saving data to app cache Set size of App Cache Clear the app cache by clearing cache Can also view app caches: ,[object Object],Private Browsing disables app cache Mobile 
Cache Manifest loading process HTTP load .manifest file Previously mentioned HTTP Caching issue Determine if new version of cache manifest Uses HTTP last-modified Change manifest file every time file changes Automate! Download
Cache events checking downloading progress with how many files downloaded, to go noupdate updateready then do window.applicationCache.swapCache()
Tips/Reference Modernizr.applicationcache Charles Proxy http://jonathanstark.com/blog/2009/09/27/debugging-html-5-offline-application-cache/ Oh, not in iOS for webkit http://stackoverflow.com/questions/4361948/offline-ios-web-app-loads-my-manifest-but-doesnt-work-offline Well, maybe from 4.3.2 http://diveintohtml5.org/offline.html
Web SQL OpenDatabase(name, version, descr, size) var db = openDatabase(‘mdb’,’1.0’,’hello world db’, 1*1024*1024) Version # is magic db.transaction(function(tx){ tx.executeSQL(‘CREATE TABLE test(id,text)’); tx.executeSQL(‘INSERT INTO test VALUES(1,”hello”)’); tx.executeSQL(‘SELECT * FROM foo’, [], callback); }); function(tx, results){// results.rows.items(i).text}
Tips Modernizr.websqldatabase Async FTW Reset db method on device DOM ERROR 11 means db broken
Other Offline Device specific libraries Calendar Contacts W3C Device APIs WG Sure, let’s call it HTML5
Products Sencha’s Ext, io jQuery offline GWT MagicPref
Hard stuff Naming Cache invalidation thx Phil Karlton
Naming Web arch anyone? http://www.w3.org/TR/webarch/ Also Roy’s thesis
Representations http://lists.w3.org/Archives/Public/www-tag/2002Oct/0079.html So, then, how do you bend a spoon? Simple. Drop a graphics processor onto the interface such that the representations are morphed. The spoon appears to bend because you have no way of distinguishing one implementation from another, unless you happen to be the One in control of the implementation.  And, because of that, bending the representations is sufficient for other observers to think that you have actually bended the spoon.
Cache Invalidation aka bending the spoon How about client-side write? Phases 0. No client side write 1. Write to server, refresh cache 2. Write to cache, then server Sync everything Deltas Choices depend upon latency What if network breaks or device shuts off partway? When to update UI?
Deltas Client actions stored as deltas in command queue Server responds with absolute or delta? Combine with Server updates If server responds with invalid state or denies command have to drain the queue and stop Hold off on UI updates if many pending requests http://googlecode.blogspot.com/2009/06/gmail-for-mobile-html5-series-cache.html
Offline detection navigator.onLine is usually just wrong Maybe message fails Or even worse, slow connection with partial message Need a ping service Tip: provide a config that you can turn on/off during app
The joy that is reliable messaging Asynchronous messaging Never do synchronous for writes No response could mean: Outbound message lost Failure on server Where on server processing? Inbound message lost Retry synchronous could mean dup messages Duplicate detection Try for idempotency
But wait, there’s more: multi-party rm scenario User buys in-app purchase Apple send back confirmation with receipt Verify receipt with your server Server talks to apple Respond to device
Security none Good luck doing crypto in js Oh, right, export laws. That’s why apple asks you every time PIN/Password to access crypto item.  Where to store the key? Need native store for security Even better, use native code for crypto
Outline Easy stuff Web Storage App Cache Web SQL Hard stuff Naming Cache invalidation Writing Oh, and security

More Related Content

What's hot

ASP.NET Web API
ASP.NET Web APIASP.NET Web API
ASP.NET Web API
habib_786
 
ASP.NET AJAX Basics
ASP.NET AJAX BasicsASP.NET AJAX Basics
ASP.NET AJAX Basics
petrov
 
Build your own PHP extension
Build your own PHP extensionBuild your own PHP extension
Build your own PHP extension
Võ Duy Tuấn
 
Building Scalable .NET Web Applications
Building Scalable .NET Web ApplicationsBuilding Scalable .NET Web Applications
Building Scalable .NET Web Applications
Buu Nguyen
 
Apex behind the scenes
Apex behind the scenesApex behind the scenes
Apex behind the scenes
Enkitec
 

What's hot (20)

Uniface Lectures Webinar - Building Responsive Applications with Uniface: Dep...
Uniface Lectures Webinar - Building Responsive Applications with Uniface: Dep...Uniface Lectures Webinar - Building Responsive Applications with Uniface: Dep...
Uniface Lectures Webinar - Building Responsive Applications with Uniface: Dep...
 
Heavy Web Optimization: Backend
Heavy Web Optimization: BackendHeavy Web Optimization: Backend
Heavy Web Optimization: Backend
 
Uniface Lectures Webinar - Application & Infrastructure Security - Hardening ...
Uniface Lectures Webinar - Application & Infrastructure Security - Hardening ...Uniface Lectures Webinar - Application & Infrastructure Security - Hardening ...
Uniface Lectures Webinar - Application & Infrastructure Security - Hardening ...
 
Top 10 Developer Mistakes That Won't Scale with SQL Server
Top 10 Developer Mistakes That Won't Scale with SQL ServerTop 10 Developer Mistakes That Won't Scale with SQL Server
Top 10 Developer Mistakes That Won't Scale with SQL Server
 
Rest api design by george reese
Rest api design by george reeseRest api design by george reese
Rest api design by george reese
 
ASP.NET Web API
ASP.NET Web APIASP.NET Web API
ASP.NET Web API
 
ASP.NET Mvc 4 web api
ASP.NET Mvc 4 web apiASP.NET Mvc 4 web api
ASP.NET Mvc 4 web api
 
PHP: Debugger, Profiler and more
PHP: Debugger, Profiler and morePHP: Debugger, Profiler and more
PHP: Debugger, Profiler and more
 
ASP.NET AJAX Basics
ASP.NET AJAX BasicsASP.NET AJAX Basics
ASP.NET AJAX Basics
 
Build your own PHP extension
Build your own PHP extensionBuild your own PHP extension
Build your own PHP extension
 
CSG 2012
CSG 2012CSG 2012
CSG 2012
 
Introduction to Magento Optimization
Introduction to Magento OptimizationIntroduction to Magento Optimization
Introduction to Magento Optimization
 
Cookies
CookiesCookies
Cookies
 
Watir
WatirWatir
Watir
 
J web socket
J web socketJ web socket
J web socket
 
Building Scalable .NET Web Applications
Building Scalable .NET Web ApplicationsBuilding Scalable .NET Web Applications
Building Scalable .NET Web Applications
 
Clustering Multiple Instances in Cold Fusion
Clustering Multiple Instances in Cold FusionClustering Multiple Instances in Cold Fusion
Clustering Multiple Instances in Cold Fusion
 
14. html 5 security considerations
14. html 5 security considerations14. html 5 security considerations
14. html 5 security considerations
 
Web Hacking Intro
Web Hacking IntroWeb Hacking Intro
Web Hacking Intro
 
Apex behind the scenes
Apex behind the scenesApex behind the scenes
Apex behind the scenes
 

Similar to Dave Orchard - Offline Web Apps with HTML5

Krug Fat Client
Krug Fat ClientKrug Fat Client
Krug Fat Client
Paul Klipp
 
Html5 : stockage local & synchronisation
Html5 : stockage local & synchronisationHtml5 : stockage local & synchronisation
Html5 : stockage local & synchronisation
goldoraf
 
HTML5 vs Silverlight
HTML5 vs SilverlightHTML5 vs Silverlight
HTML5 vs Silverlight
Matt Casto
 
01 overview-and-setup
01 overview-and-setup01 overview-and-setup
01 overview-and-setup
snopteck
 
Web app and more
Web app and moreWeb app and more
Web app and more
faming su
 

Similar to Dave Orchard - Offline Web Apps with HTML5 (20)

Play Framework: async I/O with Java and Scala
Play Framework: async I/O with Java and ScalaPlay Framework: async I/O with Java and Scala
Play Framework: async I/O with Java and Scala
 
Local storage
Local storageLocal storage
Local storage
 
Ajax to the Moon
Ajax to the MoonAjax to the Moon
Ajax to the Moon
 
Selenium
SeleniumSelenium
Selenium
 
Internet Explorer 8 for Developers by Christian Thilmany
Internet Explorer 8 for Developers by Christian ThilmanyInternet Explorer 8 for Developers by Christian Thilmany
Internet Explorer 8 for Developers by Christian Thilmany
 
"Progressive Web Apps" by Riza Fahmi (Hacktiv8)
"Progressive Web Apps" by Riza Fahmi	(Hacktiv8)"Progressive Web Apps" by Riza Fahmi	(Hacktiv8)
"Progressive Web Apps" by Riza Fahmi (Hacktiv8)
 
Progressive Web Apps. What, why and how
Progressive Web Apps. What, why and howProgressive Web Apps. What, why and how
Progressive Web Apps. What, why and how
 
HTML5 on Mobile
HTML5 on MobileHTML5 on Mobile
HTML5 on Mobile
 
Krug Fat Client
Krug Fat ClientKrug Fat Client
Krug Fat Client
 
Developing Java Web Applications
Developing Java Web ApplicationsDeveloping Java Web Applications
Developing Java Web Applications
 
Html5 : stockage local & synchronisation
Html5 : stockage local & synchronisationHtml5 : stockage local & synchronisation
Html5 : stockage local & synchronisation
 
HTML5 vs Silverlight
HTML5 vs SilverlightHTML5 vs Silverlight
HTML5 vs Silverlight
 
JavaEE6 my way
JavaEE6 my wayJavaEE6 my way
JavaEE6 my way
 
Testable client side_mvc_apps_in_javascript
Testable client side_mvc_apps_in_javascriptTestable client side_mvc_apps_in_javascript
Testable client side_mvc_apps_in_javascript
 
01 overview-and-setup
01 overview-and-setup01 overview-and-setup
01 overview-and-setup
 
Unusual Web Bugs
Unusual Web BugsUnusual Web Bugs
Unusual Web Bugs
 
Web Bugs
Web BugsWeb Bugs
Web Bugs
 
Windows Server AppFabric Caching - What it is & when you should use it?
Windows Server AppFabric Caching - What it is & when you should use it?Windows Server AppFabric Caching - What it is & when you should use it?
Windows Server AppFabric Caching - What it is & when you should use it?
 
Web Apps and more
Web Apps and moreWeb Apps and more
Web Apps and more
 
Web app and more
Web app and moreWeb app and more
Web app and more
 

More from Web Directions

Juliette Melton - Mobile User Experience Research
Juliette Melton - Mobile User Experience ResearchJuliette Melton - Mobile User Experience Research
Juliette Melton - Mobile User Experience Research
Web Directions
 
Lisa Herrod - The Age of Awareness
Lisa Herrod - The Age of AwarenessLisa Herrod - The Age of Awareness
Lisa Herrod - The Age of Awareness
Web Directions
 

More from Web Directions (20)

Douglas Crockford - Programming Style and Your Brain
Douglas Crockford - Programming Style and Your BrainDouglas Crockford - Programming Style and Your Brain
Douglas Crockford - Programming Style and Your Brain
 
Kim Heras - So, You've Got an Idea
Kim Heras - So, You've Got an IdeaKim Heras - So, You've Got an Idea
Kim Heras - So, You've Got an Idea
 
Arunan Skanthan - Roll Your own Style Guide
Arunan Skanthan - Roll Your own Style GuideArunan Skanthan - Roll Your own Style Guide
Arunan Skanthan - Roll Your own Style Guide
 
Alan Downie and Matt Milosavljevic - BugHerd, the Incubator Experience
Alan Downie and Matt Milosavljevic - BugHerd, the Incubator ExperienceAlan Downie and Matt Milosavljevic - BugHerd, the Incubator Experience
Alan Downie and Matt Milosavljevic - BugHerd, the Incubator Experience
 
Five things I know about running a digital agency
Five things I know about running a digital agencyFive things I know about running a digital agency
Five things I know about running a digital agency
 
Robby Ingebretsen - Get your game on: HTML5 for game building
Robby Ingebretsen - Get your game on: HTML5 for game buildingRobby Ingebretsen - Get your game on: HTML5 for game building
Robby Ingebretsen - Get your game on: HTML5 for game building
 
Ross Boucher - Quality Control: Testing and debugging your apps
Ross Boucher - Quality Control: Testing and debugging your appsRoss Boucher - Quality Control: Testing and debugging your apps
Ross Boucher - Quality Control: Testing and debugging your apps
 
Juliette Melton - Mobile User Experience Research
Juliette Melton - Mobile User Experience ResearchJuliette Melton - Mobile User Experience Research
Juliette Melton - Mobile User Experience Research
 
Lisa Herrod - The Age of Awareness
Lisa Herrod - The Age of AwarenessLisa Herrod - The Age of Awareness
Lisa Herrod - The Age of Awareness
 
Practising Web Standards in the Large
Practising Web Standards in the Large Practising Web Standards in the Large
Practising Web Standards in the Large
 
15 years in - Dan Hill
15 years in - Dan Hill15 years in - Dan Hill
15 years in - Dan Hill
 
WCAG2 - Gian Wild
WCAG2 - Gian WildWCAG2 - Gian Wild
WCAG2 - Gian Wild
 
CSS Frameworks
CSS FrameworksCSS Frameworks
CSS Frameworks
 
Kerry Taylor - Semantics & sensors
Kerry Taylor - Semantics & sensorsKerry Taylor - Semantics & sensors
Kerry Taylor - Semantics & sensors
 
Boosting new media accessibility - Scott Hollier
Boosting new media accessibility - Scott HollierBoosting new media accessibility - Scott Hollier
Boosting new media accessibility - Scott Hollier
 
Opening up social networks - Renato Iannella
Opening up social networks - Renato IannellaOpening up social networks - Renato Iannella
Opening up social networks - Renato Iannella
 
Douglas Crockford - Ajax Security
Douglas Crockford - Ajax SecurityDouglas Crockford - Ajax Security
Douglas Crockford - Ajax Security
 
Jeffrey Veen - Designing our way through data
Jeffrey Veen - Designing our way through dataJeffrey Veen - Designing our way through data
Jeffrey Veen - Designing our way through data
 
Nick Bolton - The evolution and commercialisation of online video
Nick Bolton - The evolution and commercialisation of online videoNick Bolton - The evolution and commercialisation of online video
Nick Bolton - The evolution and commercialisation of online video
 
Designing The User Experience Curve
Designing The User Experience CurveDesigning The User Experience Curve
Designing The User Experience Curve
 

Recently uploaded

Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 

Recently uploaded (20)

Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source Milvus
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 

Dave Orchard - Offline Web Apps with HTML5

  • 1. HTML5 and Offline David Orchard Mobile Architect
  • 2. Outline Easy stuff Web Storage App Cache Web SQL Hard stuff Naming Cache invalidation Writing Oh, and security
  • 4. Web Storage Aka HTML5 Storage SessionStorage Scoped to session No sharing across windows LocalStorage Persistent Shared across windows Size: 5M, 10M, expandable
  • 5. Web storage API setItem(key, value) sessionStorage.setItem(key, value) sessionStorage.key=value sessionStorage[‘key’]=value getItem(key) removeItem(key) length key(index) clear
  • 6. WebStorage data types String That’s it. Use JSON to serialize/deserialize structures Json.org/json2.js Careful of serializing too much
  • 7. Web storage tips/references try { return 'localStorage' in window && window['localStorage'] !== null; } catch (e) { return false; } } Modernizr.sessionstorage Modernizr.localstorage http://diveintohtml5.org/storage.html
  • 8. HTML5 Cache Manifest Central resource for html5 caching <!DOCTYPE HTML> <html manifest=“/appcache.manifest”> <body> </body> </html> Every page in your app must refer to the manifest
  • 9. Serving Cache Manifest Must be content-type text/cache-manifest Document name must end in .manifest Watch out for HTTP caching the manifest Make sure cache file gets refreshed when you refresh Can tell if clearing the cache works Or just the checking event fired (events coming up) Configure server to tell browser to not cache manifest
  • 10. Cache Manifest CACHE MANIFEST #version 13 #equivalent to CACHE: section /index.html /wickedjslib.js /awesomestyle.css NETWORK: * FALLBACK: / /fallback.html
  • 11.
  • 12. Cache Manifest loading process HTTP load .manifest file Previously mentioned HTTP Caching issue Determine if new version of cache manifest Uses HTTP last-modified Change manifest file every time file changes Automate! Download
  • 13. Cache events checking downloading progress with how many files downloaded, to go noupdate updateready then do window.applicationCache.swapCache()
  • 14. Tips/Reference Modernizr.applicationcache Charles Proxy http://jonathanstark.com/blog/2009/09/27/debugging-html-5-offline-application-cache/ Oh, not in iOS for webkit http://stackoverflow.com/questions/4361948/offline-ios-web-app-loads-my-manifest-but-doesnt-work-offline Well, maybe from 4.3.2 http://diveintohtml5.org/offline.html
  • 15. Web SQL OpenDatabase(name, version, descr, size) var db = openDatabase(‘mdb’,’1.0’,’hello world db’, 1*1024*1024) Version # is magic db.transaction(function(tx){ tx.executeSQL(‘CREATE TABLE test(id,text)’); tx.executeSQL(‘INSERT INTO test VALUES(1,”hello”)’); tx.executeSQL(‘SELECT * FROM foo’, [], callback); }); function(tx, results){// results.rows.items(i).text}
  • 16. Tips Modernizr.websqldatabase Async FTW Reset db method on device DOM ERROR 11 means db broken
  • 17. Other Offline Device specific libraries Calendar Contacts W3C Device APIs WG Sure, let’s call it HTML5
  • 18. Products Sencha’s Ext, io jQuery offline GWT MagicPref
  • 19. Hard stuff Naming Cache invalidation thx Phil Karlton
  • 20. Naming Web arch anyone? http://www.w3.org/TR/webarch/ Also Roy’s thesis
  • 21.
  • 22. Representations http://lists.w3.org/Archives/Public/www-tag/2002Oct/0079.html So, then, how do you bend a spoon? Simple. Drop a graphics processor onto the interface such that the representations are morphed. The spoon appears to bend because you have no way of distinguishing one implementation from another, unless you happen to be the One in control of the implementation. And, because of that, bending the representations is sufficient for other observers to think that you have actually bended the spoon.
  • 23. Cache Invalidation aka bending the spoon How about client-side write? Phases 0. No client side write 1. Write to server, refresh cache 2. Write to cache, then server Sync everything Deltas Choices depend upon latency What if network breaks or device shuts off partway? When to update UI?
  • 24. Deltas Client actions stored as deltas in command queue Server responds with absolute or delta? Combine with Server updates If server responds with invalid state or denies command have to drain the queue and stop Hold off on UI updates if many pending requests http://googlecode.blogspot.com/2009/06/gmail-for-mobile-html5-series-cache.html
  • 25. Offline detection navigator.onLine is usually just wrong Maybe message fails Or even worse, slow connection with partial message Need a ping service Tip: provide a config that you can turn on/off during app
  • 26. The joy that is reliable messaging Asynchronous messaging Never do synchronous for writes No response could mean: Outbound message lost Failure on server Where on server processing? Inbound message lost Retry synchronous could mean dup messages Duplicate detection Try for idempotency
  • 27. But wait, there’s more: multi-party rm scenario User buys in-app purchase Apple send back confirmation with receipt Verify receipt with your server Server talks to apple Respond to device
  • 28. Security none Good luck doing crypto in js Oh, right, export laws. That’s why apple asks you every time PIN/Password to access crypto item. Where to store the key? Need native store for security Even better, use native code for crypto
  • 29. Outline Easy stuff Web Storage App Cache Web SQL Hard stuff Naming Cache invalidation Writing Oh, and security