SlideShare a Scribd company logo
HTML5 
App Cache vs. Local Storage 
senthil | @senthil_hi
Application Cache 
A caching mechanism that enables web-based 
applications run offline
<html manifest=“appcache.mf”>* 
* Same origin as application 
* MIME type text/cache-manifest
CACHE MANIFEST 
# v1 2011-08-14 
/ressvr/z/ub/y255yxpns254thq3pohidjkjc.css?dataUri=true 
/ressvr/z/uy/jt1tg3laky0ddbaxfh5sc1il3.js 
http://thumbs3.ebaystatic.com/m/m_pqcWl7IQ-B0A/140.jpg 
http://thumbs3.ebaystatic.com/m/mSwJwMAYw/140.jpg 
# Use from network if available 
NETWORK: 
network.html 
# Fallback content 
FALLBACK: 
/assets/imgs/avatars/ assets/imgs/avatars/default-v1.png
www.spritecow.com
Modern Browsers 
& 
IE10
Local Storage 
A storage mechanism through which string 
key/value pairs can be securely stored and 
later retrieved for use.
// Setting data 
localStorage.setItem(‘userDetails’, JSON.stringify(dataObj)); 
// Retrieving the same data 
var userDetails = JSON.parse(localStorage.getItem(‘userDetails’)); 
* There is also a sessionStorage API
Follow same-origin rules
Limited to ~5MB/domain
!IE7
It’s not that simple
#1 
Files always come from App Cache, 
even if you are ONLINE 
Tip: Listen to updateready event and notify user
#2 
The App Cache only updates if the content of 
the MANIFEST itself changes 
Tip: Use version number commenting
#3 
App Cache honors HTTP Cache headers 
Tip: Check the Cache-Control & Expires headers for static resources
#4 
App Cache manifest file caches itself 
Tip: Never ever use Far-Future cache headers for manifest files. no-cache 
or 1 day expiry works best
#5 
Other non-cached resources will NOT load 
on a app cached page, even when ONLINE 
Tip: Use wildcard * in NETWORK section of manifest
Why cant we use localStorage for 
everything?
#6 
localStorage operation is 
SYNCHRONOUS
What is the perfect solution?
First Step 
Move to client side rendering
FALLBACK section of manifest is 
your friend!
CACHE MANIFEST 
# v1 2011-08-14 
/ressvr/z/ub/y255yxpns254thq3pohidjkjc.css?dataUri=true 
/ressvr/z/uy/jt1tg3laky0ddbaxfh5sc1il3.js 
/ressvr/z/uy/mustache_template.js 
http://thumbs3.ebaystatic.com/m/m_pqcWl7IQ-B0A/140.jpg 
http://thumbs3.ebaystatic.com/m/mSwJwMAYw/140.jpg 
# Use from network if available 
NETWORK: 
* 
# Fallback content 
FALLBACK: 
/tablet /tablet/pages/offline/fallback.html 
/assets/imgs/avatars/ assets/imgs/avatars/default-v1.png
Store the backend JSON data in 
localStorage 
Templates for that data in 
Application Cache
Demo
finally…
#7 
Redirect to other domains will 
show fallback page 
Tip: Remove FALLBACK from manifest, also control cache headers 
on fallback page
Again… 
Store the backend JSON data in 
localStorage 
Templates for that data in 
Application Cache
Thank You

More Related Content

What's hot

Java
JavaJava
Front-end Wonderland
Front-end WonderlandFront-end Wonderland
Front-end Wonderland
Luiz Carlos Chaves
 
Technieken & tools @ Joomla! Performance Expert Sessie
Technieken & tools @ Joomla! Performance Expert SessieTechnieken & tools @ Joomla! Performance Expert Sessie
Technieken & tools @ Joomla! Performance Expert Sessie
Sander Potjer
 
Deploying a website
Deploying a websiteDeploying a website
Deploying a website
Khirulnizam Abd Rahman
 
Browser bloat 4x3 draft 8
Browser bloat 4x3 draft 8Browser bloat 4x3 draft 8
Browser bloat 4x3 draft 8
msz
 
Joomla! XSS Vulnerabilities by Riyaz Walikar
Joomla! XSS Vulnerabilities by Riyaz WalikarJoomla! XSS Vulnerabilities by Riyaz Walikar
Joomla! XSS Vulnerabilities by Riyaz Walikar
n|u - The Open Security Community
 
Security? hey, it's only word press!
Security? hey, it's only word press!Security? hey, it's only word press!
Security? hey, it's only word press!
stk_jj
 
Open Police Design Principles - Open Belgium 2016
Open Police Design Principles - Open Belgium 2016Open Police Design Principles - Open Belgium 2016
Open Police Design Principles - Open Belgium 2016
Timble
 
Maven
MavenMaven
Progressive Enhancement
Progressive EnhancementProgressive Enhancement
Progressive Enhancement
Zach Leatherman
 
5 Skills Needed to be a Successful WebVR Developer
5 Skills Needed to be a Successful WebVR Developer5 Skills Needed to be a Successful WebVR Developer
5 Skills Needed to be a Successful WebVR Developer
Yoni Binstock
 
Caching All The Things
Caching All The ThingsCaching All The Things
Caching All The Things
Gerhard Potgieter
 
WebFormsRazor Converter VS2010 performance tips
WebFormsRazor Converter VS2010 performance tipsWebFormsRazor Converter VS2010 performance tips
WebFormsRazor Converter VS2010 performance tips
raj_kba
 
Azure Bastion Cloud swipes 01
Azure Bastion Cloud swipes   01 Azure Bastion Cloud swipes   01
Azure Bastion Cloud swipes 01
Dileepa Rajapaksa
 
Lightning Talk: JavaScript Error Handling
Lightning Talk: JavaScript Error HandlingLightning Talk: JavaScript Error Handling
Lightning Talk: JavaScript Error Handling
Nick Burwell
 
Responsive Design - WordUp Edinburgh 2011
Responsive Design - WordUp Edinburgh 2011Responsive Design - WordUp Edinburgh 2011
Responsive Design - WordUp Edinburgh 2011
Epitome Solutions Ltd
 
Cross-Browser Compatibility, and a little bit about Page Load, too.
Cross-Browser Compatibility, and a little bit about Page Load, too.Cross-Browser Compatibility, and a little bit about Page Load, too.
Cross-Browser Compatibility, and a little bit about Page Load, too.
Chad Carstensen
 
lecture5
lecture5lecture5
lecture5
tutorialsruby
 

What's hot (18)

Java
JavaJava
Java
 
Front-end Wonderland
Front-end WonderlandFront-end Wonderland
Front-end Wonderland
 
Technieken & tools @ Joomla! Performance Expert Sessie
Technieken & tools @ Joomla! Performance Expert SessieTechnieken & tools @ Joomla! Performance Expert Sessie
Technieken & tools @ Joomla! Performance Expert Sessie
 
Deploying a website
Deploying a websiteDeploying a website
Deploying a website
 
Browser bloat 4x3 draft 8
Browser bloat 4x3 draft 8Browser bloat 4x3 draft 8
Browser bloat 4x3 draft 8
 
Joomla! XSS Vulnerabilities by Riyaz Walikar
Joomla! XSS Vulnerabilities by Riyaz WalikarJoomla! XSS Vulnerabilities by Riyaz Walikar
Joomla! XSS Vulnerabilities by Riyaz Walikar
 
Security? hey, it's only word press!
Security? hey, it's only word press!Security? hey, it's only word press!
Security? hey, it's only word press!
 
Open Police Design Principles - Open Belgium 2016
Open Police Design Principles - Open Belgium 2016Open Police Design Principles - Open Belgium 2016
Open Police Design Principles - Open Belgium 2016
 
Maven
MavenMaven
Maven
 
Progressive Enhancement
Progressive EnhancementProgressive Enhancement
Progressive Enhancement
 
5 Skills Needed to be a Successful WebVR Developer
5 Skills Needed to be a Successful WebVR Developer5 Skills Needed to be a Successful WebVR Developer
5 Skills Needed to be a Successful WebVR Developer
 
Caching All The Things
Caching All The ThingsCaching All The Things
Caching All The Things
 
WebFormsRazor Converter VS2010 performance tips
WebFormsRazor Converter VS2010 performance tipsWebFormsRazor Converter VS2010 performance tips
WebFormsRazor Converter VS2010 performance tips
 
Azure Bastion Cloud swipes 01
Azure Bastion Cloud swipes   01 Azure Bastion Cloud swipes   01
Azure Bastion Cloud swipes 01
 
Lightning Talk: JavaScript Error Handling
Lightning Talk: JavaScript Error HandlingLightning Talk: JavaScript Error Handling
Lightning Talk: JavaScript Error Handling
 
Responsive Design - WordUp Edinburgh 2011
Responsive Design - WordUp Edinburgh 2011Responsive Design - WordUp Edinburgh 2011
Responsive Design - WordUp Edinburgh 2011
 
Cross-Browser Compatibility, and a little bit about Page Load, too.
Cross-Browser Compatibility, and a little bit about Page Load, too.Cross-Browser Compatibility, and a little bit about Page Load, too.
Cross-Browser Compatibility, and a little bit about Page Load, too.
 
lecture5
lecture5lecture5
lecture5
 

Viewers also liked

HTML5 Storage/Cache
HTML5 Storage/CacheHTML5 Storage/Cache
HTML5 Storage/Cache
Andy Wang
 
Understanding Asynchronous JavaScript
Understanding Asynchronous JavaScriptUnderstanding Asynchronous JavaScript
Understanding Asynchronous JavaScript
jnewmanux
 
Forms in AngularJS
Forms in AngularJSForms in AngularJS
Forms in AngularJS
Eyal Vardi
 
Callbacks, promises, generators - asynchronous javascript
Callbacks, promises, generators - asynchronous javascriptCallbacks, promises, generators - asynchronous javascript
Callbacks, promises, generators - asynchronous javascript
Łukasz Kużyński
 
Introduction to Angularjs
Introduction to AngularjsIntroduction to Angularjs
Introduction to Angularjs
Manish Shekhawat
 
Lokijs
LokijsLokijs

Viewers also liked (6)

HTML5 Storage/Cache
HTML5 Storage/CacheHTML5 Storage/Cache
HTML5 Storage/Cache
 
Understanding Asynchronous JavaScript
Understanding Asynchronous JavaScriptUnderstanding Asynchronous JavaScript
Understanding Asynchronous JavaScript
 
Forms in AngularJS
Forms in AngularJSForms in AngularJS
Forms in AngularJS
 
Callbacks, promises, generators - asynchronous javascript
Callbacks, promises, generators - asynchronous javascriptCallbacks, promises, generators - asynchronous javascript
Callbacks, promises, generators - asynchronous javascript
 
Introduction to Angularjs
Introduction to AngularjsIntroduction to Angularjs
Introduction to Angularjs
 
Lokijs
LokijsLokijs
Lokijs
 

Similar to App cache vs localStorage

Building great mobile apps: Somethings you might want to know
Building great mobile apps: Somethings you might want to knowBuilding great mobile apps: Somethings you might want to know
Building great mobile apps: Somethings you might want to know
shwetank
 
Html5 and beyond the next generation of mobile web applications - Touch Tou...
Html5 and beyond   the next generation of mobile web applications - Touch Tou...Html5 and beyond   the next generation of mobile web applications - Touch Tou...
Html5 and beyond the next generation of mobile web applications - Touch Tou...
RIA RUI Society
 
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
Timothy Oxley
 
2012-04-18-shibuyarb-offline-mobile-app-has-great-potential
2012-04-18-shibuyarb-offline-mobile-app-has-great-potential2012-04-18-shibuyarb-offline-mobile-app-has-great-potential
2012-04-18-shibuyarb-offline-mobile-app-has-great-potential
Kenichi Murahashi
 
Web application framework
Web application frameworkWeb application framework
Web application framework
Pankaj Chand
 
URL Design
URL DesignURL Design
URL Design
Walter Ebert
 
Dave Orchard - Offline Web Apps with HTML5
Dave Orchard - Offline Web Apps with HTML5Dave Orchard - Offline Web Apps with HTML5
Dave Orchard - Offline Web Apps with HTML5
Web Directions
 
Html5 oslo-code-camp
Html5 oslo-code-campHtml5 oslo-code-camp
Html5 oslo-code-camp
brucelawson
 
Web Apps and more
Web Apps and moreWeb Apps and more
Web Apps and more
Yan Shi
 
Web app and more
Web app and moreWeb app and more
Web app and more
faming su
 
Local storage
Local storageLocal storage
Local storage
Adam Crabtree
 
Always on! ... or not?
Always on! ... or not?Always on! ... or not?
Always on! ... or not?
Carsten Sandtner
 
Offline strategies for HTML5 web applications - IPC12
Offline strategies for HTML5 web applications - IPC12Offline strategies for HTML5 web applications - IPC12
Offline strategies for HTML5 web applications - IPC12
Stephan Hochdörfer
 
Taking your Web App for a walk
Taking your Web App for a walkTaking your Web App for a walk
Taking your Web App for a walk
Jens-Christian Fischer
 
Html5 cache mechanism & local storage
Html5 cache mechanism & local storageHtml5 cache mechanism & local storage
Html5 cache mechanism & local storage
Sendhil Kumar Kannan
 
HTML5 tutorial: canvas, offfline & sockets
HTML5 tutorial: canvas, offfline & socketsHTML5 tutorial: canvas, offfline & sockets
HTML5 tutorial: canvas, offfline & sockets
Remy Sharp
 
Creating Rajanikant Powered Site
Creating Rajanikant Powered SiteCreating Rajanikant Powered Site
Creating Rajanikant Powered Site
markandey
 
PHP in a mobile ecosystem
PHP in a mobile ecosystem PHP in a mobile ecosystem
PHP in a mobile ecosystem
Ivo Jansch
 
HTML5와 모바일
HTML5와 모바일HTML5와 모바일
HTML5와 모바일
ACCESS
 
Html5 Offline Applications
Html5 Offline Applications Html5 Offline Applications
Html5 Offline Applications
Sunny Sharma
 

Similar to App cache vs localStorage (20)

Building great mobile apps: Somethings you might want to know
Building great mobile apps: Somethings you might want to knowBuilding great mobile apps: Somethings you might want to know
Building great mobile apps: Somethings you might want to know
 
Html5 and beyond the next generation of mobile web applications - Touch Tou...
Html5 and beyond   the next generation of mobile web applications - Touch Tou...Html5 and beyond   the next generation of mobile web applications - Touch Tou...
Html5 and beyond the next generation of mobile web applications - Touch Tou...
 
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
 
2012-04-18-shibuyarb-offline-mobile-app-has-great-potential
2012-04-18-shibuyarb-offline-mobile-app-has-great-potential2012-04-18-shibuyarb-offline-mobile-app-has-great-potential
2012-04-18-shibuyarb-offline-mobile-app-has-great-potential
 
Web application framework
Web application frameworkWeb application framework
Web application framework
 
URL Design
URL DesignURL Design
URL Design
 
Dave Orchard - Offline Web Apps with HTML5
Dave Orchard - Offline Web Apps with HTML5Dave Orchard - Offline Web Apps with HTML5
Dave Orchard - Offline Web Apps with HTML5
 
Html5 oslo-code-camp
Html5 oslo-code-campHtml5 oslo-code-camp
Html5 oslo-code-camp
 
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
 
Local storage
Local storageLocal storage
Local storage
 
Always on! ... or not?
Always on! ... or not?Always on! ... or not?
Always on! ... or not?
 
Offline strategies for HTML5 web applications - IPC12
Offline strategies for HTML5 web applications - IPC12Offline strategies for HTML5 web applications - IPC12
Offline strategies for HTML5 web applications - IPC12
 
Taking your Web App for a walk
Taking your Web App for a walkTaking your Web App for a walk
Taking your Web App for a walk
 
Html5 cache mechanism & local storage
Html5 cache mechanism & local storageHtml5 cache mechanism & local storage
Html5 cache mechanism & local storage
 
HTML5 tutorial: canvas, offfline & sockets
HTML5 tutorial: canvas, offfline & socketsHTML5 tutorial: canvas, offfline & sockets
HTML5 tutorial: canvas, offfline & sockets
 
Creating Rajanikant Powered Site
Creating Rajanikant Powered SiteCreating Rajanikant Powered Site
Creating Rajanikant Powered Site
 
PHP in a mobile ecosystem
PHP in a mobile ecosystem PHP in a mobile ecosystem
PHP in a mobile ecosystem
 
HTML5와 모바일
HTML5와 모바일HTML5와 모바일
HTML5와 모바일
 
Html5 Offline Applications
Html5 Offline Applications Html5 Offline Applications
Html5 Offline Applications
 

Recently uploaded

SENTIMENT ANALYSIS ON PPT AND Project template_.pptx
SENTIMENT ANALYSIS ON PPT AND Project template_.pptxSENTIMENT ANALYSIS ON PPT AND Project template_.pptx
SENTIMENT ANALYSIS ON PPT AND Project template_.pptx
b0754201
 
4. Mosca vol I -Fisica-Tipler-5ta-Edicion-Vol-1.pdf
4. Mosca vol I -Fisica-Tipler-5ta-Edicion-Vol-1.pdf4. Mosca vol I -Fisica-Tipler-5ta-Edicion-Vol-1.pdf
4. Mosca vol I -Fisica-Tipler-5ta-Edicion-Vol-1.pdf
Gino153088
 
SCALING OF MOS CIRCUITS m .pptx
SCALING OF MOS CIRCUITS m                 .pptxSCALING OF MOS CIRCUITS m                 .pptx
SCALING OF MOS CIRCUITS m .pptx
harshapolam10
 
Software Engineering and Project Management - Software Testing + Agile Method...
Software Engineering and Project Management - Software Testing + Agile Method...Software Engineering and Project Management - Software Testing + Agile Method...
Software Engineering and Project Management - Software Testing + Agile Method...
Prakhyath Rai
 
一比一原版(uoft毕业证书)加拿大多伦多大学毕业证如何办理
一比一原版(uoft毕业证书)加拿大多伦多大学毕业证如何办理一比一原版(uoft毕业证书)加拿大多伦多大学毕业证如何办理
一比一原版(uoft毕业证书)加拿大多伦多大学毕业证如何办理
sydezfe
 
UNIT 4 LINEAR INTEGRATED CIRCUITS-DIGITAL ICS
UNIT 4 LINEAR INTEGRATED CIRCUITS-DIGITAL ICSUNIT 4 LINEAR INTEGRATED CIRCUITS-DIGITAL ICS
UNIT 4 LINEAR INTEGRATED CIRCUITS-DIGITAL ICS
vmspraneeth
 
Height and depth gauge linear metrology.pdf
Height and depth gauge linear metrology.pdfHeight and depth gauge linear metrology.pdf
Height and depth gauge linear metrology.pdf
q30122000
 
OOPS_Lab_Manual - programs using C++ programming language
OOPS_Lab_Manual - programs using C++ programming languageOOPS_Lab_Manual - programs using C++ programming language
OOPS_Lab_Manual - programs using C++ programming language
PreethaV16
 
一比一原版(uofo毕业证书)美国俄勒冈大学毕业证如何办理
一比一原版(uofo毕业证书)美国俄勒冈大学毕业证如何办理一比一原版(uofo毕业证书)美国俄勒冈大学毕业证如何办理
一比一原版(uofo毕业证书)美国俄勒冈大学毕业证如何办理
upoux
 
AI-Based Home Security System : Home security
AI-Based Home Security System : Home securityAI-Based Home Security System : Home security
AI-Based Home Security System : Home security
AIRCC Publishing Corporation
 
Software Engineering and Project Management - Introduction, Modeling Concepts...
Software Engineering and Project Management - Introduction, Modeling Concepts...Software Engineering and Project Management - Introduction, Modeling Concepts...
Software Engineering and Project Management - Introduction, Modeling Concepts...
Prakhyath Rai
 
Applications of artificial Intelligence in Mechanical Engineering.pdf
Applications of artificial Intelligence in Mechanical Engineering.pdfApplications of artificial Intelligence in Mechanical Engineering.pdf
Applications of artificial Intelligence in Mechanical Engineering.pdf
Atif Razi
 
Accident detection system project report.pdf
Accident detection system project report.pdfAccident detection system project report.pdf
Accident detection system project report.pdf
Kamal Acharya
 
Tools & Techniques for Commissioning and Maintaining PV Systems W-Animations ...
Tools & Techniques for Commissioning and Maintaining PV Systems W-Animations ...Tools & Techniques for Commissioning and Maintaining PV Systems W-Animations ...
Tools & Techniques for Commissioning and Maintaining PV Systems W-Animations ...
Transcat
 
2. protection of river banks and bed erosion protection works.ppt
2. protection of river banks and bed erosion protection works.ppt2. protection of river banks and bed erosion protection works.ppt
2. protection of river banks and bed erosion protection works.ppt
abdatawakjira
 
Digital Twins Computer Networking Paper Presentation.pptx
Digital Twins Computer Networking Paper Presentation.pptxDigital Twins Computer Networking Paper Presentation.pptx
Digital Twins Computer Networking Paper Presentation.pptx
aryanpankaj78
 
Blood finder application project report (1).pdf
Blood finder application project report (1).pdfBlood finder application project report (1).pdf
Blood finder application project report (1).pdf
Kamal Acharya
 
Transformers design and coooling methods
Transformers design and coooling methodsTransformers design and coooling methods
Transformers design and coooling methods
Roger Rozario
 
LLM Fine Tuning with QLoRA Cassandra Lunch 4, presented by Anant
LLM Fine Tuning with QLoRA Cassandra Lunch 4, presented by AnantLLM Fine Tuning with QLoRA Cassandra Lunch 4, presented by Anant
LLM Fine Tuning with QLoRA Cassandra Lunch 4, presented by Anant
Anant Corporation
 
Prediction of Electrical Energy Efficiency Using Information on Consumer's Ac...
Prediction of Electrical Energy Efficiency Using Information on Consumer's Ac...Prediction of Electrical Energy Efficiency Using Information on Consumer's Ac...
Prediction of Electrical Energy Efficiency Using Information on Consumer's Ac...
PriyankaKilaniya
 

Recently uploaded (20)

SENTIMENT ANALYSIS ON PPT AND Project template_.pptx
SENTIMENT ANALYSIS ON PPT AND Project template_.pptxSENTIMENT ANALYSIS ON PPT AND Project template_.pptx
SENTIMENT ANALYSIS ON PPT AND Project template_.pptx
 
4. Mosca vol I -Fisica-Tipler-5ta-Edicion-Vol-1.pdf
4. Mosca vol I -Fisica-Tipler-5ta-Edicion-Vol-1.pdf4. Mosca vol I -Fisica-Tipler-5ta-Edicion-Vol-1.pdf
4. Mosca vol I -Fisica-Tipler-5ta-Edicion-Vol-1.pdf
 
SCALING OF MOS CIRCUITS m .pptx
SCALING OF MOS CIRCUITS m                 .pptxSCALING OF MOS CIRCUITS m                 .pptx
SCALING OF MOS CIRCUITS m .pptx
 
Software Engineering and Project Management - Software Testing + Agile Method...
Software Engineering and Project Management - Software Testing + Agile Method...Software Engineering and Project Management - Software Testing + Agile Method...
Software Engineering and Project Management - Software Testing + Agile Method...
 
一比一原版(uoft毕业证书)加拿大多伦多大学毕业证如何办理
一比一原版(uoft毕业证书)加拿大多伦多大学毕业证如何办理一比一原版(uoft毕业证书)加拿大多伦多大学毕业证如何办理
一比一原版(uoft毕业证书)加拿大多伦多大学毕业证如何办理
 
UNIT 4 LINEAR INTEGRATED CIRCUITS-DIGITAL ICS
UNIT 4 LINEAR INTEGRATED CIRCUITS-DIGITAL ICSUNIT 4 LINEAR INTEGRATED CIRCUITS-DIGITAL ICS
UNIT 4 LINEAR INTEGRATED CIRCUITS-DIGITAL ICS
 
Height and depth gauge linear metrology.pdf
Height and depth gauge linear metrology.pdfHeight and depth gauge linear metrology.pdf
Height and depth gauge linear metrology.pdf
 
OOPS_Lab_Manual - programs using C++ programming language
OOPS_Lab_Manual - programs using C++ programming languageOOPS_Lab_Manual - programs using C++ programming language
OOPS_Lab_Manual - programs using C++ programming language
 
一比一原版(uofo毕业证书)美国俄勒冈大学毕业证如何办理
一比一原版(uofo毕业证书)美国俄勒冈大学毕业证如何办理一比一原版(uofo毕业证书)美国俄勒冈大学毕业证如何办理
一比一原版(uofo毕业证书)美国俄勒冈大学毕业证如何办理
 
AI-Based Home Security System : Home security
AI-Based Home Security System : Home securityAI-Based Home Security System : Home security
AI-Based Home Security System : Home security
 
Software Engineering and Project Management - Introduction, Modeling Concepts...
Software Engineering and Project Management - Introduction, Modeling Concepts...Software Engineering and Project Management - Introduction, Modeling Concepts...
Software Engineering and Project Management - Introduction, Modeling Concepts...
 
Applications of artificial Intelligence in Mechanical Engineering.pdf
Applications of artificial Intelligence in Mechanical Engineering.pdfApplications of artificial Intelligence in Mechanical Engineering.pdf
Applications of artificial Intelligence in Mechanical Engineering.pdf
 
Accident detection system project report.pdf
Accident detection system project report.pdfAccident detection system project report.pdf
Accident detection system project report.pdf
 
Tools & Techniques for Commissioning and Maintaining PV Systems W-Animations ...
Tools & Techniques for Commissioning and Maintaining PV Systems W-Animations ...Tools & Techniques for Commissioning and Maintaining PV Systems W-Animations ...
Tools & Techniques for Commissioning and Maintaining PV Systems W-Animations ...
 
2. protection of river banks and bed erosion protection works.ppt
2. protection of river banks and bed erosion protection works.ppt2. protection of river banks and bed erosion protection works.ppt
2. protection of river banks and bed erosion protection works.ppt
 
Digital Twins Computer Networking Paper Presentation.pptx
Digital Twins Computer Networking Paper Presentation.pptxDigital Twins Computer Networking Paper Presentation.pptx
Digital Twins Computer Networking Paper Presentation.pptx
 
Blood finder application project report (1).pdf
Blood finder application project report (1).pdfBlood finder application project report (1).pdf
Blood finder application project report (1).pdf
 
Transformers design and coooling methods
Transformers design and coooling methodsTransformers design and coooling methods
Transformers design and coooling methods
 
LLM Fine Tuning with QLoRA Cassandra Lunch 4, presented by Anant
LLM Fine Tuning with QLoRA Cassandra Lunch 4, presented by AnantLLM Fine Tuning with QLoRA Cassandra Lunch 4, presented by Anant
LLM Fine Tuning with QLoRA Cassandra Lunch 4, presented by Anant
 
Prediction of Electrical Energy Efficiency Using Information on Consumer's Ac...
Prediction of Electrical Energy Efficiency Using Information on Consumer's Ac...Prediction of Electrical Energy Efficiency Using Information on Consumer's Ac...
Prediction of Electrical Energy Efficiency Using Information on Consumer's Ac...
 

App cache vs localStorage

  • 1. HTML5 App Cache vs. Local Storage senthil | @senthil_hi
  • 2. Application Cache A caching mechanism that enables web-based applications run offline
  • 3. <html manifest=“appcache.mf”>* * Same origin as application * MIME type text/cache-manifest
  • 4. CACHE MANIFEST # v1 2011-08-14 /ressvr/z/ub/y255yxpns254thq3pohidjkjc.css?dataUri=true /ressvr/z/uy/jt1tg3laky0ddbaxfh5sc1il3.js http://thumbs3.ebaystatic.com/m/m_pqcWl7IQ-B0A/140.jpg http://thumbs3.ebaystatic.com/m/mSwJwMAYw/140.jpg # Use from network if available NETWORK: network.html # Fallback content FALLBACK: /assets/imgs/avatars/ assets/imgs/avatars/default-v1.png
  • 7. Local Storage A storage mechanism through which string key/value pairs can be securely stored and later retrieved for use.
  • 8. // Setting data localStorage.setItem(‘userDetails’, JSON.stringify(dataObj)); // Retrieving the same data var userDetails = JSON.parse(localStorage.getItem(‘userDetails’)); * There is also a sessionStorage API
  • 11. !IE7
  • 12. It’s not that simple
  • 13. #1 Files always come from App Cache, even if you are ONLINE Tip: Listen to updateready event and notify user
  • 14. #2 The App Cache only updates if the content of the MANIFEST itself changes Tip: Use version number commenting
  • 15. #3 App Cache honors HTTP Cache headers Tip: Check the Cache-Control & Expires headers for static resources
  • 16. #4 App Cache manifest file caches itself Tip: Never ever use Far-Future cache headers for manifest files. no-cache or 1 day expiry works best
  • 17. #5 Other non-cached resources will NOT load on a app cached page, even when ONLINE Tip: Use wildcard * in NETWORK section of manifest
  • 18. Why cant we use localStorage for everything?
  • 19. #6 localStorage operation is SYNCHRONOUS
  • 20. What is the perfect solution?
  • 21. First Step Move to client side rendering
  • 22. FALLBACK section of manifest is your friend!
  • 23. CACHE MANIFEST # v1 2011-08-14 /ressvr/z/ub/y255yxpns254thq3pohidjkjc.css?dataUri=true /ressvr/z/uy/jt1tg3laky0ddbaxfh5sc1il3.js /ressvr/z/uy/mustache_template.js http://thumbs3.ebaystatic.com/m/m_pqcWl7IQ-B0A/140.jpg http://thumbs3.ebaystatic.com/m/mSwJwMAYw/140.jpg # Use from network if available NETWORK: * # Fallback content FALLBACK: /tablet /tablet/pages/offline/fallback.html /assets/imgs/avatars/ assets/imgs/avatars/default-v1.png
  • 24. Store the backend JSON data in localStorage Templates for that data in Application Cache
  • 25. Demo
  • 27. #7 Redirect to other domains will show fallback page Tip: Remove FALLBACK from manifest, also control cache headers on fallback page
  • 28. Again… Store the backend JSON data in localStorage Templates for that data in Application Cache

Editor's Notes

  1. Cache manifest should be the first line The main URL is part of the cache Allows other domains
  2. Everything will be JS based, big JS & CSS reading, eval is a problem, also image handling
  3. Offline - 404, 500 etc. Original connection needs to fail – flaky connection