SlideShare a Scribd company logo
Your browser, my storage
a new approach on data storing
Francesco Fullone
ff AT ideato.it
Who am I
Francesco Fullone aka Fullo
- PHP developer since 1999
- President
- and Open Source Evangelist
- CEO @
- 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
Cookies are introduced in
HTTP/1.0, limited to only 20 per
domain and 4KB each.
http://www.flickr.com/photos/betsyweber/4962298614/
Cookies are sent to
and from client at
any connection.
http://www.flickr.com/photos/dionhinchcliffe/4326080515
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.
Adobe, in 2002, 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 is 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.
All these storage systems had
different APIs, a common
platform is needed by all the
browser vendors.
Your browser, my storage
The two approaches of storing:
Application Cache
Offline storage
Application Caching involves
saving the application's core logic
and user-interface.
http://www.whatwg.org/specs/web-apps/current-
work/#applicationcache
It is enabled by a file .manifest
that declares which resources
have to be saved locally.
(limited to 5MB).
CACHE MANIFEST
# Explicitly cached entries
CACHE:
index.html
stylesheet.css
images/logo.png
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
Data storage is about
capturing specific
data, or resources the
user has expressed
interest in.
http://www.flickr.com/photos/bfionline/2380398365/
Approaches to
Data Storage
Web Storage is the simpler
implementation of the Data
Storage paradigm.
http://dev.w3.org/html5/webstorage/
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 just an
offline SQL implementation,
based on SQLite.
http://dev.w3.org/html5/webdatabase/
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 (yet)
supported by Microsoft and
Mozilla, instead it is on browsers
based on webkit.
IndexedDB is a nice compromise
between Web Storage and Web
SQL Database.
http://www.w3.org/TR/IndexedDB/
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
officially supported by anyone!
Firefox 4 beta has a partial implementation.
FileAPI or File Storage will give
us a way to store a lot of data.
http://www.w3.org/TR/FileAPI/
File API includes FileReader and
FileWriter APIs.
Actually (FileReader) is partially supported only by
Chrome.
First steps on
offline storage
development.
http://www.flickr.com/photos/45449692@N00/3161567381
HTML 5 Confusion
Detect if the storing feature is
supported by the browser (with
modernizr), otherwise degradate
to something else.
(ie. dojox.storage)
Protect against lost data,
sync automatically.
http://www.flickr.com/photos/neate_photos/3529558272/
Automatically detect when
users are online.
http://www.flickr.com/photos/doctorow/2686237951/
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.
?
phpDay 2011
12-14 Maggio 2011
www.phpday.it
via Quinto Bucci 205
47023 Cesena (FC)
info AT ideato.it
www.ideato.it
rate this talk: http://joind.in/2126

More Related Content

RTF
Seting Database Dreamveaver
PPT
Krug Fat Client
PPTX
Posting Images using Android
PDF
your browser, your storage
PDF
Your browser, your storage (extended version)
PDF
Introduction to Web Designing
PDF
Web Browsers - Their Main working
PPTX
Mongodb tutorial by Rajendra Arora
Seting Database Dreamveaver
Krug Fat Client
Posting Images using Android
your browser, your storage
Your browser, your storage (extended version)
Introduction to Web Designing
Web Browsers - Their Main working
Mongodb tutorial by Rajendra Arora

What's hot (20)

PPTX
Accessing mongo DB In Mule ESB
PPTX
HTML 5
PDF
Varnish more than a cache
PPTX
World wide web architecture presentation
PDF
WordCamp Fayetteville 2018: Flipping The Switch On A New Website
PDF
Plone.restapi - a bridge to the modern web
PPTX
JS digest. Decemebr 2017
ODP
MongoDB PhillyDB database throw down
PPT
introduction to web application development
PPT
Web Fundamentals
ODP
Chrome extension development
PPTX
Type URL, Enter, and Then …
PDF
Php & web server performace
PDF
Introduction to WebSockets Presentation
PDF
Linux Hosting Training Course [Level 1] - Lec 7
PPTX
Websockets in Node.js - Making them reliable and scalable
PDF
Memcache and Drupal - Vaibhav Jain
PDF
Caching
PPTX
PDF
Speed up your site with Varnish
Accessing mongo DB In Mule ESB
HTML 5
Varnish more than a cache
World wide web architecture presentation
WordCamp Fayetteville 2018: Flipping The Switch On A New Website
Plone.restapi - a bridge to the modern web
JS digest. Decemebr 2017
MongoDB PhillyDB database throw down
introduction to web application development
Web Fundamentals
Chrome extension development
Type URL, Enter, and Then …
Php & web server performace
Introduction to WebSockets Presentation
Linux Hosting Training Course [Level 1] - Lec 7
Websockets in Node.js - Making them reliable and scalable
Memcache and Drupal - Vaibhav Jain
Caching
Speed up your site with Varnish
Ad

Similar to Your browser, my storage (20)

PDF
your browser, my storage
PDF
An Overview of HTML5 Storage
PPTX
Local storage
PPTX
Notes on SF W3Conf
PPTX
Web storage
PPTX
In-browser storage and me
PDF
HTML5 Storage/Cache
PPT
Persistent Offline Storage White
PPTX
HTML5 Local Storage
PDF
Html5-Web-Storage
PDF
Beyond Cookies, Persistent Storage For Web Applications Web Directions North ...
PPTX
Client side storage on the modern web
PPT
Html5三种本地存储方式的比较
PPTX
Html5 storage and browser storage
PDF
Html5 storage suggestions for challenges.pptx
PDF
Naked and afraid Offline Mobile
PDF
Naked and afraid Offline mobile
PDF
Client-side storage
PDF
HTML5 Client-side Storage
PDF
Get Ahead with HTML5 on Moible
your browser, my storage
An Overview of HTML5 Storage
Local storage
Notes on SF W3Conf
Web storage
In-browser storage and me
HTML5 Storage/Cache
Persistent Offline Storage White
HTML5 Local Storage
Html5-Web-Storage
Beyond Cookies, Persistent Storage For Web Applications Web Directions North ...
Client side storage on the modern web
Html5三种本地存储方式的比较
Html5 storage and browser storage
Html5 storage suggestions for challenges.pptx
Naked and afraid Offline Mobile
Naked and afraid Offline mobile
Client-side storage
HTML5 Client-side Storage
Get Ahead with HTML5 on Moible
Ad

More from Francesco Fullone (20)

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

Recently uploaded (20)

PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PPTX
Machine Learning_overview_presentation.pptx
PPTX
sap open course for s4hana steps from ECC to s4
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PPT
Teaching material agriculture food technology
PDF
Electronic commerce courselecture one. Pdf
PPTX
Spectroscopy.pptx food analysis technology
PDF
NewMind AI Weekly Chronicles - August'25-Week II
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Unlocking AI with Model Context Protocol (MCP)
PPTX
A Presentation on Artificial Intelligence
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Machine learning based COVID-19 study performance prediction
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
Encapsulation_ Review paper, used for researhc scholars
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Machine Learning_overview_presentation.pptx
sap open course for s4hana steps from ECC to s4
Reach Out and Touch Someone: Haptics and Empathic Computing
Programs and apps: productivity, graphics, security and other tools
The Rise and Fall of 3GPP – Time for a Sabbatical?
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Teaching material agriculture food technology
Electronic commerce courselecture one. Pdf
Spectroscopy.pptx food analysis technology
NewMind AI Weekly Chronicles - August'25-Week II
Per capita expenditure prediction using model stacking based on satellite ima...
Unlocking AI with Model Context Protocol (MCP)
A Presentation on Artificial Intelligence
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Mobile App Security Testing_ A Comprehensive Guide.pdf
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Machine learning based COVID-19 study performance prediction
Dropbox Q2 2025 Financial Results & Investor Presentation

Your browser, my storage