SlideShare a Scribd company logo
1 of 56
Download to read offline
Your browser, my storage
a new approach on data storing   (v.1.2)




Francesco Fullone
ff AT ideato.it
Who am I

Francesco Fullone aka Fullo

- PHP developer since 1999
-               President
-         and Open Source Evangelist
- CEO @
- founder @


- Nerd and geek
What we want is a lot of storage space, on
the client, that persists beyond a page
refresh and isn’t transmitted to the server.


                                ~ M. Pilgrim
Persistent local storage is one of
     the areas where client
  applications traditionally win
    against web applications.
A jump in the past
http://qrurl.it/r/3l




  Cookies were introduced in
HTTP/1.0, limited to only 20 per
    domain and 4KB each.
Cookies are sent to
                        and from client at
                         any connection.



http://qrurl.it/r/3m
Microsoft with Internet Explorer 6
   introduced dHTML and the
userData API to store up to 64KB
             of data
Mozilla introduced with Firefox 2
the DOM Storage API, it will then
     know as Web Storage.
In 2002 Adobe
                          created the
                    Flash Cookies aka
  “Local Shared Objects” for Flash 6
Data storage increased to 100KB but it
              was difficult to be used
With Flash 8, in 2006,
 Adobe introduced the
  ExternalInterface
 to allow Js to access
to the stored resources.
Between 2005 and 2007
 dojox.storage was written by
  Brad Neuberg as a Js->Flash
bridge to manage bigger chunks
           of data

      (with user prompt over 1MB).
Google created Gears in 2007,
 that introduced a database
paradigm (based on SQLite) to
    the storage problem.
BUT
All these storage systems had
  different APIs, a common
platform is needed by all the
       browser vendors.
The two approaches of storing:
      Application Cache
       Offline storage
Application Caching involves
saving the application's core logic
       and user-interface.

           http://qrurl.it/r/3g
It is enabled by a file .appcache
  that declares which resources
     have to be saved locally.

       (theoretically limited to 5MB).
CACHE MANIFEST

# Explicitly cached entries
CACHE:
index.html
stylesheet.css
images/logo.png
http://www.anothersite.com/scripts/main.js
# Resources that require the user to be online.
NETWORK:
login.php
/myapi
http://api.twitter.com
# static.html will be served if main.php is inaccessible
# offline.jpg will be served in place of all images in images/large/
FALLBACK:
/main.php /static.html
images/large/ images/offline.jpg
.avi images/offline.jpg
applicationCache can use events
 to trigger application behavior

 window.applicationCache.onchecking = function(e) {
     log("Checking for application update");
 }
applicationCache or check if the
        browser is online

  If (window.navigator.onLine) {
      log("Application is online");
  }
Chrome/Chromium doesn't support
window.navigator.onLine attribute and...




   It doesn't have a real offline mode!
As stated in the specs:
“window.navigator.onLine is inherently
unreliable. A computer can be connected
    to a network without having Internet
                                 access.”
If you change a
                       resource and you
                     don't update (rev)
                     the .appcache file
                   the browser may not
                 download the new file!
(yes! cached resources have priority on the online ones)
Data storage is about
                         capturing specific
                       data, or resources the
                        user has expressed
                            interest in.
http://qrurl.it/r/3n
Approaches to
Data Storage
Web Storage is the simpler
implementation of the Data
    Storage paradigm.

       http://qrurl.it/r/3h
Web Storage is based on a
structure of key-value pairs like
     any JavaScript object.

localStorage.setItem("bar", foo);
Web Storage can save up to 5MB
but only as strings. So we have
 to force a casting if needed.

var bar = parseInt(localStorage["bar"]);
Web Storage should be local
 based or session based.

 var bar = localStorage["bar"];
var foo = sessionStorage["foo"];
sessionStorage mantains a
storage area that's available for
the duration of the web session.

 Opening a new window/tab will create a new
                  session.
localStorage relies only on
  client, so we have to track
changes and use storage.events
  to sync server and client if
            needed.
Web SQL Database is WAS just
an offline SQL implementation,
        based on SQLite.

         http://qrurl.it/r/3i
this.db = openDatabase('geomood', '1.0', 'Geo', 8192);
this.db.transaction(function(tx) {
  tx.executeSql("create table if not exists checkins(id
               integer primary key asc, time integer,
               latitude float, longitude float, mood
               string)",
               [],
                function() { console.log("siucc"); }
          »   );
});
Web SQL Database is not
 supported by Microsoft and
Mozilla, it is on browsers based
           on webkit.
But ...
Web SQL Database is dead!
  as being dropped by W3C from 18/11/10



             why bother more?
Web SQL
Database is the
only database
storage engine
 that works on
mobile devices!
IndexedDB is a nice compromise
 between Web Storage and Web
        SQL Database.

         http://qrurl.it/r/3j
IndexedDB allows to create an
index on a certain field stored in
 a standard key->value mapping.
IndexedDB is promoted by all
browsers vendor, but is not yet
    fully supported by all

  Firefox 4, Chrome 11, have full implementation.
             Safari 5.1 and IE 10 will have
FileAPI allows to manipulate file
       objects, as well as
  programmatically select them
      and access their data.

          http://qrurl.it/r/3k
File API includes FileReader and
         FileWriter APIs.

       Actually is supported by Chrome,
    Firefox > 3.6, Safari > 5.1, Opera > 11.1.
First steps on
                          offline storage
                          development.

http://flic.kr/p/5PnRQr
Storages Status/1
Storages Status/2
Detect if the storing feature is
 supported by the browser (with
modernizr), otherwise degradate
       to something else.
           (ie. dojox.storage)
Use libraries that manage data
             for you


       (ie. storagejs, lawnchair)
http://qrurl.it/r/3o




Protect against lost data,
  sync automatically.
http://qrurl.it/r/3p




                Automatically detect when
                    users are online.
Do not exceed in storing data,
you can store binary data base64
  encoded but remember the
    pitfalls in performance.
Avoid race conditions.
If possible use WebSQL to use its
     transactions features.
use local storage to help your
application to become faster.
?
jsDay + phpDay 2012
 16-19 Maggio 2012 Verona
     www.phpday.it
Francesco Fullone
    ff@ideato.it
       @fullo



  via Quinto Bucci 205
   47023 Cesena (FC)
    info AT ideato.it
     www.ideato.it

More Related Content

What's hot

Apache Server Tutorial
Apache Server TutorialApache Server Tutorial
Apache Server TutorialJagat Kothari
 
Web browser architecture.87 to 88
Web browser architecture.87 to 88Web browser architecture.87 to 88
Web browser architecture.87 to 88myrajendra
 
Web browser architecture
Web browser architectureWeb browser architecture
Web browser architectureNguyen Quang
 
Apache Web Server Architecture Chaitanya Kulkarni
Apache Web Server Architecture Chaitanya KulkarniApache Web Server Architecture Chaitanya Kulkarni
Apache Web Server Architecture Chaitanya Kulkarniwebhostingguy
 
Quickly Customizing Alfresco
Quickly Customizing AlfrescoQuickly Customizing Alfresco
Quickly Customizing AlfrescoAlfresco Software
 
Web server installation_configuration_apache
Web server installation_configuration_apacheWeb server installation_configuration_apache
Web server installation_configuration_apacheShaojie Yang
 
Windows on Hadoop: Integrating the Desktop and the Apache Hadoop Linux Platform
Windows on Hadoop: Integrating the Desktop and the Apache Hadoop Linux PlatformWindows on Hadoop: Integrating the Desktop and the Apache Hadoop Linux Platform
Windows on Hadoop: Integrating the Desktop and the Apache Hadoop Linux PlatformDataWorks Summit
 
Apache Web server Complete Guide
Apache Web server Complete GuideApache Web server Complete Guide
Apache Web server Complete Guidewebhostingguy
 

What's hot (20)

Mla Databases
Mla DatabasesMla Databases
Mla Databases
 
Apache Server Tutorial
Apache Server TutorialApache Server Tutorial
Apache Server Tutorial
 
How Browser Works?
How Browser Works?How Browser Works?
How Browser Works?
 
Web browser architecture.87 to 88
Web browser architecture.87 to 88Web browser architecture.87 to 88
Web browser architecture.87 to 88
 
.htaccess
.htaccess.htaccess
.htaccess
 
Web browser
Web browserWeb browser
Web browser
 
Web browser architecture
Web browser architectureWeb browser architecture
Web browser architecture
 
Local Drupal MultiSite Set-up
Local Drupal MultiSite Set-upLocal Drupal MultiSite Set-up
Local Drupal MultiSite Set-up
 
Apache Web Server Architecture Chaitanya Kulkarni
Apache Web Server Architecture Chaitanya KulkarniApache Web Server Architecture Chaitanya Kulkarni
Apache Web Server Architecture Chaitanya Kulkarni
 
Quickly Customizing Alfresco
Quickly Customizing AlfrescoQuickly Customizing Alfresco
Quickly Customizing Alfresco
 
Web server installation_configuration_apache
Web server installation_configuration_apacheWeb server installation_configuration_apache
Web server installation_configuration_apache
 
introduction to web application development
introduction to web application developmentintroduction to web application development
introduction to web application development
 
Apache web server
Apache web serverApache web server
Apache web server
 
Apache Web Server Setup 3
Apache Web Server Setup 3Apache Web Server Setup 3
Apache Web Server Setup 3
 
Windows on Hadoop: Integrating the Desktop and the Apache Hadoop Linux Platform
Windows on Hadoop: Integrating the Desktop and the Apache Hadoop Linux PlatformWindows on Hadoop: Integrating the Desktop and the Apache Hadoop Linux Platform
Windows on Hadoop: Integrating the Desktop and the Apache Hadoop Linux Platform
 
5-WebServers.ppt
5-WebServers.ppt5-WebServers.ppt
5-WebServers.ppt
 
Apache Web Server Setup 1
Apache Web Server Setup 1Apache Web Server Setup 1
Apache Web Server Setup 1
 
Apache Web server Complete Guide
Apache Web server Complete GuideApache Web server Complete Guide
Apache Web server Complete Guide
 
Presentation
PresentationPresentation
Presentation
 
Apache Ppt
Apache PptApache Ppt
Apache Ppt
 

Similar to Your browser, your storage (extended version)

Krug Fat Client
Krug Fat ClientKrug Fat Client
Krug Fat ClientPaul Klipp
 
Caching objects-in-memory
Caching objects-in-memoryCaching objects-in-memory
Caching objects-in-memoryMauro Cassani
 
Don't touch the mobile parts
Don't touch the mobile partsDon't touch the mobile parts
Don't touch the mobile partsFrancesco Fullone
 
Top 10 HTML5 Features for Oracle Cloud Developers
Top 10 HTML5 Features for Oracle Cloud DevelopersTop 10 HTML5 Features for Oracle Cloud Developers
Top 10 HTML5 Features for Oracle Cloud DevelopersBrian Huff
 
Study notes for CompTIA Certified Advanced Security Practitioner (ver2)
Study notes for CompTIA Certified Advanced Security Practitioner  (ver2)Study notes for CompTIA Certified Advanced Security Practitioner  (ver2)
Study notes for CompTIA Certified Advanced Security Practitioner (ver2)David Sweigert
 
Strategies for Context Data Persistence
Strategies for Context Data PersistenceStrategies for Context Data Persistence
Strategies for Context Data PersistenceFIWARE
 
Academy PRO: HTML5 Data storage
Academy PRO: HTML5 Data storageAcademy PRO: HTML5 Data storage
Academy PRO: HTML5 Data storageBinary Studio
 
Html5 - Awesome APIs
Html5 - Awesome APIsHtml5 - Awesome APIs
Html5 - Awesome APIsDragos Ionita
 
Introduction to Filecoin
Introduction to Filecoin   Introduction to Filecoin
Introduction to Filecoin Vanessa Lošić
 
Caching and Its Main Types
Caching and Its Main TypesCaching and Its Main Types
Caching and Its Main TypesHTS Hosting
 
Containers and Databases
Containers and DatabasesContainers and Databases
Containers and DatabasesFernando Ike
 
My First Hadoop Program !!!
My First Hadoop Program !!!My First Hadoop Program !!!
My First Hadoop Program !!!Ayapparaj SKS
 
Decentralized possibilities with filecoin & ipfs_encode filecoin club
Decentralized possibilities with filecoin & ipfs_encode filecoin clubDecentralized possibilities with filecoin & ipfs_encode filecoin club
Decentralized possibilities with filecoin & ipfs_encode filecoin clubKlaraOrban
 

Similar to Your browser, your storage (extended version) (20)

Your browser, my storage
Your browser, my storageYour browser, my storage
Your browser, my storage
 
Html5
Html5Html5
Html5
 
Krug Fat Client
Krug Fat ClientKrug Fat Client
Krug Fat Client
 
Scaling PHP apps
Scaling PHP appsScaling PHP apps
Scaling PHP apps
 
Web storage
Web storage Web storage
Web storage
 
Caching objects-in-memory
Caching objects-in-memoryCaching objects-in-memory
Caching objects-in-memory
 
Don't touch the mobile parts
Don't touch the mobile partsDon't touch the mobile parts
Don't touch the mobile parts
 
Mobile Web
Mobile WebMobile Web
Mobile Web
 
Internet test
Internet testInternet test
Internet test
 
Caching By Nyros Developer
Caching By Nyros DeveloperCaching By Nyros Developer
Caching By Nyros Developer
 
Top 10 HTML5 Features for Oracle Cloud Developers
Top 10 HTML5 Features for Oracle Cloud DevelopersTop 10 HTML5 Features for Oracle Cloud Developers
Top 10 HTML5 Features for Oracle Cloud Developers
 
Study notes for CompTIA Certified Advanced Security Practitioner (ver2)
Study notes for CompTIA Certified Advanced Security Practitioner  (ver2)Study notes for CompTIA Certified Advanced Security Practitioner  (ver2)
Study notes for CompTIA Certified Advanced Security Practitioner (ver2)
 
Strategies for Context Data Persistence
Strategies for Context Data PersistenceStrategies for Context Data Persistence
Strategies for Context Data Persistence
 
Academy PRO: HTML5 Data storage
Academy PRO: HTML5 Data storageAcademy PRO: HTML5 Data storage
Academy PRO: HTML5 Data storage
 
Html5 - Awesome APIs
Html5 - Awesome APIsHtml5 - Awesome APIs
Html5 - Awesome APIs
 
Introduction to Filecoin
Introduction to Filecoin   Introduction to Filecoin
Introduction to Filecoin
 
Caching and Its Main Types
Caching and Its Main TypesCaching and Its Main Types
Caching and Its Main Types
 
Containers and Databases
Containers and DatabasesContainers and Databases
Containers and Databases
 
My First Hadoop Program !!!
My First Hadoop Program !!!My First Hadoop Program !!!
My First Hadoop Program !!!
 
Decentralized possibilities with filecoin & ipfs_encode filecoin club
Decentralized possibilities with filecoin & ipfs_encode filecoin clubDecentralized possibilities with filecoin & ipfs_encode filecoin club
Decentralized possibilities with filecoin & ipfs_encode filecoin club
 

More from Francesco Fullone

Life Cycle Design e Circular Economy: un caso reale
Life Cycle Design e Circular Economy: un caso reale Life Cycle Design e Circular Economy: un caso reale
Life Cycle Design e Circular Economy: un caso reale Francesco Fullone
 
Okr istruzioni per l'uso - devfest
Okr   istruzioni per l'uso - devfestOkr   istruzioni per l'uso - devfest
Okr istruzioni per l'uso - devfestFrancesco Fullone
 
OKR, sono veramente utili alla mia azienda?
OKR, sono veramente utili alla mia azienda?OKR, sono veramente utili alla mia azienda?
OKR, sono veramente utili alla mia azienda?Francesco Fullone
 
Open Governance, un caso reale
Open Governance, un caso realeOpen Governance, un caso reale
Open Governance, un caso realeFrancesco Fullone
 
A recommendation engine for your applications
A recommendation engine for your applicationsA recommendation engine for your applications
A recommendation engine for your applicationsFrancesco Fullone
 
A recommendation engine for your applications
A recommendation engine for your applicationsA recommendation engine for your applications
A recommendation engine for your applicationsFrancesco Fullone
 
MVP & Startup, with OpenSource Software and Microsoft Azure
MVP & Startup, with OpenSource Software and Microsoft AzureMVP & Startup, with OpenSource Software and Microsoft Azure
MVP & Startup, with OpenSource Software and Microsoft AzureFrancesco Fullone
 
Help yourself, grow an healthy ecosystem
Help yourself, grow an healthy ecosystemHelp yourself, grow an healthy ecosystem
Help yourself, grow an healthy ecosystemFrancesco Fullone
 
Outsourcing, partners or suppliers?
Outsourcing, partners or suppliers?Outsourcing, partners or suppliers?
Outsourcing, partners or suppliers?Francesco Fullone
 
From brainstorming to product development
From brainstorming to product developmentFrom brainstorming to product development
From brainstorming to product developmentFrancesco Fullone
 
Compromises and not solution
Compromises and not solutionCompromises and not solution
Compromises and not solutionFrancesco Fullone
 
From webagency to...a better job, life and a lot of fun
From webagency to...a better job, life and a lot of funFrom webagency to...a better job, life and a lot of fun
From webagency to...a better job, life and a lot of funFrancesco Fullone
 

More from Francesco Fullone (20)

Life Cycle Design e Circular Economy: un caso reale
Life Cycle Design e Circular Economy: un caso reale Life Cycle Design e Circular Economy: un caso reale
Life Cycle Design e Circular Economy: un caso reale
 
Okr istruzioni per l'uso - devfest
Okr   istruzioni per l'uso - devfestOkr   istruzioni per l'uso - devfest
Okr istruzioni per l'uso - devfest
 
OKR, sono veramente utili alla mia azienda?
OKR, sono veramente utili alla mia azienda?OKR, sono veramente utili alla mia azienda?
OKR, sono veramente utili alla mia azienda?
 
Okr per community - icms
Okr   per community - icmsOkr   per community - icms
Okr per community - icms
 
Open Governance, un caso reale
Open Governance, un caso realeOpen Governance, un caso reale
Open Governance, un caso reale
 
A recommendation engine for your applications
A recommendation engine for your applicationsA recommendation engine for your applications
A recommendation engine for your applications
 
A recommendation engine for your applications
A recommendation engine for your applicationsA recommendation engine for your applications
A recommendation engine for your applications
 
Con te non ci lavoro
Con te non ci lavoroCon te non ci lavoro
Con te non ci lavoro
 
Con te non ci lavoro
Con te non ci lavoroCon te non ci lavoro
Con te non ci lavoro
 
Continuous budgeting
Continuous budgetingContinuous budgeting
Continuous budgeting
 
Remote working istruzioni
Remote working istruzioniRemote working istruzioni
Remote working istruzioni
 
Remote working istruzioni
Remote working istruzioniRemote working istruzioni
Remote working istruzioni
 
MVP & Startup, with OpenSource Software and Microsoft Azure
MVP & Startup, with OpenSource Software and Microsoft AzureMVP & Startup, with OpenSource Software and Microsoft Azure
MVP & Startup, with OpenSource Software and Microsoft Azure
 
Remote working istruzioni
Remote working istruzioniRemote working istruzioni
Remote working istruzioni
 
Help yourself, grow an healthy ecosystem
Help yourself, grow an healthy ecosystemHelp yourself, grow an healthy ecosystem
Help yourself, grow an healthy ecosystem
 
Outsourcing, partners or suppliers?
Outsourcing, partners or suppliers?Outsourcing, partners or suppliers?
Outsourcing, partners or suppliers?
 
From brainstorming to product development
From brainstorming to product developmentFrom brainstorming to product development
From brainstorming to product development
 
Compromises and not solution
Compromises and not solutionCompromises and not solution
Compromises and not solution
 
PHP Goes Enterprise
PHP Goes EnterprisePHP Goes Enterprise
PHP Goes Enterprise
 
From webagency to...a better job, life and a lot of fun
From webagency to...a better job, life and a lot of funFrom webagency to...a better job, life and a lot of fun
From webagency to...a better job, life and a lot of fun
 

Recently uploaded

Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistandanishmna97
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusZilliz
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
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 businesspanagenda
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityWSO2
 
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...apidays
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Orbitshub
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...apidays
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024The Digital Insurer
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Zilliz
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Victor Rentea
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Zilliz
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 

Recently uploaded (20)

Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
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
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
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...
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 

Your browser, your storage (extended version)

  • 1. Your browser, my storage a new approach on data storing (v.1.2) Francesco Fullone ff AT ideato.it
  • 2. Who am I Francesco Fullone aka Fullo - PHP developer since 1999 - President - and Open Source Evangelist - CEO @ - founder @ - Nerd and geek
  • 3. What we want is a lot of storage space, on the client, that persists beyond a page refresh and isn’t transmitted to the server. ~ M. Pilgrim
  • 4. Persistent local storage is one of the areas where client applications traditionally win against web applications.
  • 5. A jump in the past
  • 6. http://qrurl.it/r/3l Cookies were introduced in HTTP/1.0, limited to only 20 per domain and 4KB each.
  • 7. Cookies are sent to and from client at any connection. http://qrurl.it/r/3m
  • 8. Microsoft with Internet Explorer 6 introduced dHTML and the userData API to store up to 64KB of data
  • 9. Mozilla introduced with Firefox 2 the DOM Storage API, it will then know as Web Storage.
  • 10. In 2002 Adobe created the Flash Cookies aka “Local Shared Objects” for Flash 6 Data storage increased to 100KB but it was difficult to be used
  • 11. With Flash 8, in 2006, Adobe introduced the ExternalInterface to allow Js to access to the stored resources.
  • 12. Between 2005 and 2007 dojox.storage was written by Brad Neuberg as a Js->Flash bridge to manage bigger chunks of data (with user prompt over 1MB).
  • 13. Google created Gears in 2007, that introduced a database paradigm (based on SQLite) to the storage problem.
  • 14. BUT
  • 15. All these storage systems had different APIs, a common platform is needed by all the browser vendors.
  • 16.
  • 17. The two approaches of storing: Application Cache Offline storage
  • 18. Application Caching involves saving the application's core logic and user-interface. http://qrurl.it/r/3g
  • 19. It is enabled by a file .appcache that declares which resources have to be saved locally. (theoretically limited to 5MB).
  • 20. CACHE MANIFEST # Explicitly cached entries CACHE: index.html stylesheet.css images/logo.png http://www.anothersite.com/scripts/main.js # Resources that require the user to be online. NETWORK: login.php /myapi http://api.twitter.com # static.html will be served if main.php is inaccessible # offline.jpg will be served in place of all images in images/large/ FALLBACK: /main.php /static.html images/large/ images/offline.jpg .avi images/offline.jpg
  • 21. applicationCache can use events to trigger application behavior window.applicationCache.onchecking = function(e) { log("Checking for application update"); }
  • 22. applicationCache or check if the browser is online If (window.navigator.onLine) { log("Application is online"); }
  • 23. Chrome/Chromium doesn't support window.navigator.onLine attribute and... It doesn't have a real offline mode!
  • 24. As stated in the specs: “window.navigator.onLine is inherently unreliable. A computer can be connected to a network without having Internet access.”
  • 25. If you change a resource and you don't update (rev) the .appcache file the browser may not download the new file! (yes! cached resources have priority on the online ones)
  • 26. Data storage is about capturing specific data, or resources the user has expressed interest in. http://qrurl.it/r/3n
  • 28. Web Storage is the simpler implementation of the Data Storage paradigm. http://qrurl.it/r/3h
  • 29. Web Storage is based on a structure of key-value pairs like any JavaScript object. localStorage.setItem("bar", foo);
  • 30. Web Storage can save up to 5MB but only as strings. So we have to force a casting if needed. var bar = parseInt(localStorage["bar"]);
  • 31. Web Storage should be local based or session based. var bar = localStorage["bar"]; var foo = sessionStorage["foo"];
  • 32. sessionStorage mantains a storage area that's available for the duration of the web session. Opening a new window/tab will create a new session.
  • 33. localStorage relies only on client, so we have to track changes and use storage.events to sync server and client if needed.
  • 34. Web SQL Database is WAS just an offline SQL implementation, based on SQLite. http://qrurl.it/r/3i
  • 35. this.db = openDatabase('geomood', '1.0', 'Geo', 8192); this.db.transaction(function(tx) { tx.executeSql("create table if not exists checkins(id integer primary key asc, time integer, latitude float, longitude float, mood string)", [], function() { console.log("siucc"); } » ); });
  • 36. Web SQL Database is not supported by Microsoft and Mozilla, it is on browsers based on webkit.
  • 37. But ... Web SQL Database is dead! as being dropped by W3C from 18/11/10 why bother more?
  • 38. Web SQL Database is the only database storage engine that works on mobile devices!
  • 39. IndexedDB is a nice compromise between Web Storage and Web SQL Database. http://qrurl.it/r/3j
  • 40. IndexedDB allows to create an index on a certain field stored in a standard key->value mapping.
  • 41. IndexedDB is promoted by all browsers vendor, but is not yet fully supported by all Firefox 4, Chrome 11, have full implementation. Safari 5.1 and IE 10 will have
  • 42. FileAPI allows to manipulate file objects, as well as programmatically select them and access their data. http://qrurl.it/r/3k
  • 43. File API includes FileReader and FileWriter APIs. Actually is supported by Chrome, Firefox > 3.6, Safari > 5.1, Opera > 11.1.
  • 44. First steps on offline storage development. http://flic.kr/p/5PnRQr
  • 47. Detect if the storing feature is supported by the browser (with modernizr), otherwise degradate to something else. (ie. dojox.storage)
  • 48. Use libraries that manage data for you (ie. storagejs, lawnchair)
  • 49. http://qrurl.it/r/3o Protect against lost data, sync automatically.
  • 50. http://qrurl.it/r/3p Automatically detect when users are online.
  • 51. Do not exceed in storing data, you can store binary data base64 encoded but remember the pitfalls in performance.
  • 52. Avoid race conditions. If possible use WebSQL to use its transactions features.
  • 53. use local storage to help your application to become faster.
  • 54. ?
  • 55. jsDay + phpDay 2012 16-19 Maggio 2012 Verona www.phpday.it
  • 56. Francesco Fullone ff@ideato.it @fullo via Quinto Bucci 205 47023 Cesena (FC) info AT ideato.it www.ideato.it