SlideShare ist ein Scribd-Unternehmen logo
1 von 24
Downloaden Sie, um offline zu lesen
Web Storage
Presenter: Vinod Mohan
Presenter: Vinod MohanPresenter: Vinod Mohan
What is Web Storage?
Web storage and DOM storage (document object
model) are web application software methods and protocols
used for storing data in a web browser. Web storage
supports persistent data storage, similar to cookies but with
a greatly enhanced capacity and no information stored in
the HTTP request header.
Presenter: Vinod Mohan
Why Store Data in Web Browser
The main reason is practicality. JavaScript code running
on the browser does not necessarily need to send all
information to the server. There are several use cases:
●
You want to increase performance. You can cache data
client-side so it can be retrieved without additional server
requests.
●
You have a significant quantity of client-side-only data,
e.g. HTML strings or widget configuration settings.
●
You want you make your application work off-line.
Presenter: Vinod MohanPresenter: Vinod Mohan
What we are using now?
Cookies:- Cookies were invented early in the web’s history,
and indeed they can be used for persistent local storage of
small amounts of data.
Cookies are domain-specific chunks of data. They sound
tasty, but handling is awkward.
Presenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod Mohan
How Cookies work?
●
Server sends some data to the visitor's browser
in the form of cookie.
●
The browser stores the same as plain text record
on the visitor's hard drive.
●
Now, When the visitor arrive at the another page
on the same site, the browser sends the same
cookie to server for retrival.
●
Once retrived, your server knows/remembers
what was stores earlier
Presenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod Mohan
The Limitations of Cookies
●
Cookies are included with every HTTP request, thereby
sending data unencrypted over the internet(unless SSL
verified) and transmitting the same data over and over
●
Cookies have data limitations, about to 4KB per cookie
●
Most browers allowed limited number of cookies per
domain.
●
Privacy and Security issues
Presenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod Mohan
What we really want is?
●
Lot of storage space.
●
Data should persists beyond a page refresh.
●
Data should not be transmitted to server
●
On the Browser
Presenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod Mohan
Introducing HTML5 Web Storage
HTML5 Web Storage is a way for web pages to store
named key/value pairs locally, within the client web
browser. Like cookies, this data persists even after you
navigate away from the web site, close your browser tab,
exit your browser, or what have you.
Presenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod Mohan
Browser support
Presenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod Mohan
Before HTML5
●
At first, Started in IE. Microsoft invented a great
many things, DHTML Behaviors(userData). UserData
allows 64 KB per domain.
●
In 2002, Adobe introduced flash cookies in flash
environment, properly known as Local Shared Object
allows upto 100 KB of data per domain.
●
Brad Neuberg developed an early prototype of a Flash
to-JavaScript bridge called AMASS (AJAX Massive
Storage System), but it was limited by some of Flash’s
design quirks.
Presenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod Mohan
Before HTML5 continued
●
By 2006, with the advent of ExternalInterface in Flash 8,
accessing LSOs from JavaScript became an order of
magnitude easier and faster.
●
Brad rewrote AMASS and integrated it into the popular
Dojo Toolkit under the moniker dojox.storage. Flash
gives each domain 100 KB of storage “for free”.
●
In 2007, Google launched Gears, provided an API to an
embedded SQL database based on SQLite.
Presenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod Mohan
Web Storage types
Web Storage comes in two flavours and both uses
the Key-value pair combination,
1. Local Storage,
Exists untill it is removed or expired and available
across multiple tabs
2. Session Storage,
Once the window or tab is closed, the data stored
is erased.
Presenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod Mohan
Web Storage Strengths
●
The ease of use for developers: It has a simple AOI to
get and set key/value pairs and can do much more.
●
The amount of space provided: no less than 5 or 10 MB
per domain.
●
The LocalStorage object stores data with no expiration.
●
Clent- Side Access: Servers cannot directly write into
web storage.
●
Data transmission: Objects are not sent automatically
with each request but must be requested.
Presenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod Mohan
Web Storage Weaknesses
●
Data is stored as a simple string.
●
It has default 5 MB limit; more storage can be allowed
by user if required.
●
It can be disabled by the user or systems administrator.
●
Storage can be slow with complex sets of data
Presenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod Mohan
Web Storage APIs
●
setItem(Key, Value) – Adds an item to storage
●
getItem(Key) - Retrives an item from storage
●
removeItem(Key) – Removes an item from storage
●
Clear() - Removes all items from storage
●
key(n) - Returns the name of the key for the index
provided
●
Length - Number of key/value pairs in the storage list
Presenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod Mohan
How to check browser supports or not?
// is localStorage available?
if (typeof window.localStorage != "undefined") {
alert(“Storage is working.”);
} else {
alert(“Storage is not working.”)
}
You can download JS at http://modernizr.com/
Presenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod Mohan
Working of setItem(key, value)
// is localStorage available?
if (typeof window.localStorage != "undefined") {
// Local storage
localStorage.setItem("hello", "Hello World!");
//Session storage
sessionStorage.setItem("hello", "Hello World!");
} else {
alert(“Storage is not working.”)
}
Presenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod Mohan
Working of getItem(key)
// is localStorage available?
if (typeof window.localStorage != "undefined") {
// Local storage
var local = localStorage.getItem("hello");
alert(hello + “from Local Storage”);
//Session storage
var session = sessionStorage.setItem("hello");
alert(hello + “from Session Storage”);
} else {
alert(“Storage is not working.”)
}
Presenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod Mohan
Working of removeItem(key)
// is localStorage available?
if (typeof window.localStorage != "undefined") {
// Local storage
localStorage.removeItem("hello");
//Session storage
sessionStorage.removeItem("hello");
} else {
alert(“Storage is not working.”)
}
Presenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod Mohan
Working of clear, key & Length
//to clear all
localStorage.clear();
//to read all
for (var i = 0; i < localStorage.length; i++) {
var key = localStorage.key(i);
var data = localStorage[key];
console.log(data);
}
Presenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod Mohan
Storage Event
●
When ever we store data in local storage, event is fired
in other windows/tabs
●
This event can be used to synchronice the data in
defferent tabs
Syntax:
window.addEventListener('storage', function(event) {
console.log('The value for '+event.key+' changes from
'+event.oldValue+' to '+event.newValue);
}) ;
Presenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod Mohan
Storage Event
●
When ever we store data in local storage, event is fired
in other windows/tabs
●
This event can be used to synchronice the data in
defferent tabs
Syntax:
window.addEventListener('storage', function(event) {
console.log('The value for '+event.key+' changes from
'+event.oldValue+' to '+event.newValue);
}) ;
Presenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod Mohan
References
Presenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod Mohan
●
http://www.sitepoint.com/html5-web-storage
●
http://www.html5rocks.com/en/features/storage
●
http://diveintohtml5.info/storage.html
Examples:
●
http://www.ellipsetours.com/Demos/storage/
●
http://html5demos.com/storage
Presenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod Mohan
Presenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod Mohan
Thank You
Email: vinodm@mindfiresolutions.com,
Skype: mfsi_vinodm,
Mob No: +91 – 9620453625.
Presenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod Mohan

Weitere ähnliche Inhalte

Was ist angesagt?

ASP.NET Web API
ASP.NET Web APIASP.NET Web API
ASP.NET Web API
habib_786
 

Was ist angesagt? (20)

Python/Flask Presentation
Python/Flask PresentationPython/Flask Presentation
Python/Flask Presentation
 
html5.ppt
html5.ppthtml5.ppt
html5.ppt
 
IIS
IISIIS
IIS
 
Cookies and sessions
Cookies and sessionsCookies and sessions
Cookies and sessions
 
Backend Programming
Backend ProgrammingBackend Programming
Backend Programming
 
Learn react-js
Learn react-jsLearn react-js
Learn react-js
 
Session tracking in servlets
Session tracking in servletsSession tracking in servlets
Session tracking in servlets
 
The virtual DOM and how react uses it internally
The virtual DOM and how react uses it internallyThe virtual DOM and how react uses it internally
The virtual DOM and how react uses it internally
 
Front-end development introduction (HTML, CSS). Part 1
Front-end development introduction (HTML, CSS). Part 1Front-end development introduction (HTML, CSS). Part 1
Front-end development introduction (HTML, CSS). Part 1
 
CSS3 Media Queries
CSS3 Media QueriesCSS3 Media Queries
CSS3 Media Queries
 
Basics of JavaScript
Basics of JavaScriptBasics of JavaScript
Basics of JavaScript
 
Document Object Model
Document Object ModelDocument Object Model
Document Object Model
 
Webservices
WebservicesWebservices
Webservices
 
ASP.NET Web API
ASP.NET Web APIASP.NET Web API
ASP.NET Web API
 
JavaScript: Events Handling
JavaScript: Events HandlingJavaScript: Events Handling
JavaScript: Events Handling
 
Introduction to React JS
Introduction to React JSIntroduction to React JS
Introduction to React JS
 
Html JavaScript and CSS
Html JavaScript and CSSHtml JavaScript and CSS
Html JavaScript and CSS
 
Introduction to HTML5
Introduction to HTML5Introduction to HTML5
Introduction to HTML5
 
Angular
AngularAngular
Angular
 
Php Presentation
Php PresentationPhp Presentation
Php Presentation
 

Andere mochten auch

Django e il Rap Elia Contini
Django e il Rap Elia ContiniDjango e il Rap Elia Contini
Django e il Rap Elia Contini
WEBdeBS
 

Andere mochten auch (20)

PyCon 2012: Python for data lovers: explore it, analyze it, map it
PyCon 2012: Python for data lovers: explore it, analyze it, map it PyCon 2012: Python for data lovers: explore it, analyze it, map it
PyCon 2012: Python for data lovers: explore it, analyze it, map it
 
Html5 web storage
Html5 web storageHtml5 web storage
Html5 web storage
 
Html5 OffLine Database
Html5 OffLine DatabaseHtml5 OffLine Database
Html5 OffLine Database
 
Web Storage & Web Workers
Web Storage & Web WorkersWeb Storage & Web Workers
Web Storage & Web Workers
 
Super Advanced Python –act1
Super Advanced Python –act1Super Advanced Python –act1
Super Advanced Python –act1
 
Django - The Web framework for perfectionists with deadlines
Django - The Web framework for perfectionists with deadlinesDjango - The Web framework for perfectionists with deadlines
Django - The Web framework for perfectionists with deadlines
 
Django e il Rap Elia Contini
Django e il Rap Elia ContiniDjango e il Rap Elia Contini
Django e il Rap Elia Contini
 
PythonBrasil[8] closing
PythonBrasil[8] closingPythonBrasil[8] closing
PythonBrasil[8] closing
 
2 × 3 = 6
2 × 3 = 62 × 3 = 6
2 × 3 = 6
 
Bottle - Python Web Microframework
Bottle - Python Web MicroframeworkBottle - Python Web Microframework
Bottle - Python Web Microframework
 
라이트닝 토크 2015 파이콘
라이트닝 토크 2015 파이콘라이트닝 토크 2015 파이콘
라이트닝 토크 2015 파이콘
 
Website optimization
Website optimizationWebsite optimization
Website optimization
 
Digesting jQuery
Digesting jQueryDigesting jQuery
Digesting jQuery
 
2016 py con2016_lightingtalk_php to python
2016 py con2016_lightingtalk_php to python2016 py con2016_lightingtalk_php to python
2016 py con2016_lightingtalk_php to python
 
Rabbitmq & Postgresql
Rabbitmq & PostgresqlRabbitmq & Postgresql
Rabbitmq & Postgresql
 
Django - The Web framework for perfectionists with deadlines
Django - The Web framework  for perfectionists with deadlinesDjango - The Web framework  for perfectionists with deadlines
Django - The Web framework for perfectionists with deadlines
 
The Django Book, Chapter 16: django.contrib
The Django Book, Chapter 16: django.contribThe Django Book, Chapter 16: django.contrib
The Django Book, Chapter 16: django.contrib
 
Overview of Testing Talks at Pycon
Overview of Testing Talks at PyconOverview of Testing Talks at Pycon
Overview of Testing Talks at Pycon
 
Load testing
Load testingLoad testing
Load testing
 
Django-Queryset
Django-QuerysetDjango-Queryset
Django-Queryset
 

Ähnlich wie Html5-Web-Storage

Mobile Meow at Mobilism
Mobile Meow at MobilismMobile Meow at Mobilism
Mobile Meow at Mobilism
Greg Schechter
 
Debugging Web Apps on Real Mobile Devices
Debugging Web Apps on Real Mobile DevicesDebugging Web Apps on Real Mobile Devices
Debugging Web Apps on Real Mobile Devices
Dale Lane
 
Mongo Seattle - The Business of MongoDB
Mongo Seattle - The Business of MongoDBMongo Seattle - The Business of MongoDB
Mongo Seattle - The Business of MongoDB
Justin Smestad
 

Ähnlich wie Html5-Web-Storage (20)

Varnish at the BBC
Varnish at the BBCVarnish at the BBC
Varnish at the BBC
 
Make Browser Extensions Great Again
Make Browser Extensions Great AgainMake Browser Extensions Great Again
Make Browser Extensions Great Again
 
Engage 2022: The Superpower of Integrating External APIs for Notes and Domino...
Engage 2022: The Superpower of Integrating External APIs for Notes and Domino...Engage 2022: The Superpower of Integrating External APIs for Notes and Domino...
Engage 2022: The Superpower of Integrating External APIs for Notes and Domino...
 
Apache Flex and the imperfect Web
Apache Flex and the imperfect WebApache Flex and the imperfect Web
Apache Flex and the imperfect Web
 
Mobile Meow at Mobilism
Mobile Meow at MobilismMobile Meow at Mobilism
Mobile Meow at Mobilism
 
Debugging Web Apps on Real Mobile Devices
Debugging Web Apps on Real Mobile DevicesDebugging Web Apps on Real Mobile Devices
Debugging Web Apps on Real Mobile Devices
 
Web DU Mobile Meow
Web DU Mobile MeowWeb DU Mobile Meow
Web DU Mobile Meow
 
MongoDB.local Austin 2018: PetroCloud: MongoDB for the Industrial IOT Ecosystem
MongoDB.local Austin 2018: PetroCloud: MongoDB for the Industrial IOT EcosystemMongoDB.local Austin 2018: PetroCloud: MongoDB for the Industrial IOT Ecosystem
MongoDB.local Austin 2018: PetroCloud: MongoDB for the Industrial IOT Ecosystem
 
JS Days Mobile Meow
JS Days Mobile MeowJS Days Mobile Meow
JS Days Mobile Meow
 
HTML 5
HTML 5HTML 5
HTML 5
 
IDEALIZE 2023 - NodeJS & Firebase Session
IDEALIZE 2023 - NodeJS & Firebase SessionIDEALIZE 2023 - NodeJS & Firebase Session
IDEALIZE 2023 - NodeJS & Firebase Session
 
(In)Security Implication in the JS Universe
(In)Security Implication in the JS Universe(In)Security Implication in the JS Universe
(In)Security Implication in the JS Universe
 
Strategies for Context Data Persistence
Strategies for Context Data PersistenceStrategies for Context Data Persistence
Strategies for Context Data Persistence
 
Static site gen talk
Static site gen talkStatic site gen talk
Static site gen talk
 
Learn More About Object Store | MuleSoft Mysore Meetup #9
Learn More About Object Store | MuleSoft Mysore Meetup #9Learn More About Object Store | MuleSoft Mysore Meetup #9
Learn More About Object Store | MuleSoft Mysore Meetup #9
 
20 tips for website performance
20 tips for website performance20 tips for website performance
20 tips for website performance
 
Mongo Seattle - The Business of MongoDB
Mongo Seattle - The Business of MongoDBMongo Seattle - The Business of MongoDB
Mongo Seattle - The Business of MongoDB
 
Webinar: Customer Scale
Webinar: Customer ScaleWebinar: Customer Scale
Webinar: Customer Scale
 
Mobile for PHP developers
Mobile for PHP developersMobile for PHP developers
Mobile for PHP developers
 
JS Days HTML5 Flash and the Battle for Faster Cat Videos
JS Days HTML5 Flash and the Battle for Faster Cat VideosJS Days HTML5 Flash and the Battle for Faster Cat Videos
JS Days HTML5 Flash and the Battle for Faster Cat Videos
 

Mehr von Mindfire Solutions

Mehr von Mindfire Solutions (20)

Physician Search and Review
Physician Search and ReviewPhysician Search and Review
Physician Search and Review
 
diet management app
diet management appdiet management app
diet management app
 
Business Technology Solution
Business Technology SolutionBusiness Technology Solution
Business Technology Solution
 
Remote Health Monitoring
Remote Health MonitoringRemote Health Monitoring
Remote Health Monitoring
 
Influencer Marketing Solution
Influencer Marketing SolutionInfluencer Marketing Solution
Influencer Marketing Solution
 
ELMAH
ELMAHELMAH
ELMAH
 
High Availability of Azure Applications
High Availability of Azure ApplicationsHigh Availability of Azure Applications
High Availability of Azure Applications
 
IOT Hands On
IOT Hands OnIOT Hands On
IOT Hands On
 
Glimpse of Loops Vs Set
Glimpse of Loops Vs SetGlimpse of Loops Vs Set
Glimpse of Loops Vs Set
 
Oracle Sql Developer-Getting Started
Oracle Sql Developer-Getting StartedOracle Sql Developer-Getting Started
Oracle Sql Developer-Getting Started
 
Adaptive Layout In iOS 8
Adaptive Layout In iOS 8Adaptive Layout In iOS 8
Adaptive Layout In iOS 8
 
Introduction to Auto-layout : iOS/Mac
Introduction to Auto-layout : iOS/MacIntroduction to Auto-layout : iOS/Mac
Introduction to Auto-layout : iOS/Mac
 
LINQPad - utility Tool
LINQPad - utility ToolLINQPad - utility Tool
LINQPad - utility Tool
 
Get started with watch kit development
Get started with watch kit developmentGet started with watch kit development
Get started with watch kit development
 
Swift vs Objective-C
Swift vs Objective-CSwift vs Objective-C
Swift vs Objective-C
 
Material Design in Android
Material Design in AndroidMaterial Design in Android
Material Design in Android
 
Introduction to OData
Introduction to ODataIntroduction to OData
Introduction to OData
 
Ext js Part 2- MVC
Ext js Part 2- MVCExt js Part 2- MVC
Ext js Part 2- MVC
 
ExtJs Basic Part-1
ExtJs Basic Part-1ExtJs Basic Part-1
ExtJs Basic Part-1
 
Spring Security Introduction
Spring Security IntroductionSpring Security Introduction
Spring Security Introduction
 

Kürzlich hochgeladen

%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
masabamasaba
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
masabamasaba
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
VishalKumarJha10
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
masabamasaba
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
mohitmore19
 

Kürzlich hochgeladen (20)

%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
 
Exploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfExploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdf
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the past
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
 
Chinsurah Escorts ☎️8617697112 Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ☎️8617697112  Starting From 5K to 15K High Profile Escorts ...Chinsurah Escorts ☎️8617697112  Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ☎️8617697112 Starting From 5K to 15K High Profile Escorts ...
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdf
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
SHRMPro HRMS Software Solutions Presentation
SHRMPro HRMS Software Solutions PresentationSHRMPro HRMS Software Solutions Presentation
SHRMPro HRMS Software Solutions Presentation
 

Html5-Web-Storage

  • 2. Presenter: Vinod MohanPresenter: Vinod Mohan What is Web Storage? Web storage and DOM storage (document object model) are web application software methods and protocols used for storing data in a web browser. Web storage supports persistent data storage, similar to cookies but with a greatly enhanced capacity and no information stored in the HTTP request header.
  • 3. Presenter: Vinod Mohan Why Store Data in Web Browser The main reason is practicality. JavaScript code running on the browser does not necessarily need to send all information to the server. There are several use cases: ● You want to increase performance. You can cache data client-side so it can be retrieved without additional server requests. ● You have a significant quantity of client-side-only data, e.g. HTML strings or widget configuration settings. ● You want you make your application work off-line.
  • 4. Presenter: Vinod MohanPresenter: Vinod Mohan What we are using now? Cookies:- Cookies were invented early in the web’s history, and indeed they can be used for persistent local storage of small amounts of data. Cookies are domain-specific chunks of data. They sound tasty, but handling is awkward.
  • 5. Presenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod Mohan How Cookies work? ● Server sends some data to the visitor's browser in the form of cookie. ● The browser stores the same as plain text record on the visitor's hard drive. ● Now, When the visitor arrive at the another page on the same site, the browser sends the same cookie to server for retrival. ● Once retrived, your server knows/remembers what was stores earlier
  • 6. Presenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod Mohan The Limitations of Cookies ● Cookies are included with every HTTP request, thereby sending data unencrypted over the internet(unless SSL verified) and transmitting the same data over and over ● Cookies have data limitations, about to 4KB per cookie ● Most browers allowed limited number of cookies per domain. ● Privacy and Security issues
  • 7. Presenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod Mohan What we really want is? ● Lot of storage space. ● Data should persists beyond a page refresh. ● Data should not be transmitted to server ● On the Browser
  • 8. Presenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod Mohan Introducing HTML5 Web Storage HTML5 Web Storage is a way for web pages to store named key/value pairs locally, within the client web browser. Like cookies, this data persists even after you navigate away from the web site, close your browser tab, exit your browser, or what have you.
  • 9. Presenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod Mohan Browser support
  • 10. Presenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod Mohan Before HTML5 ● At first, Started in IE. Microsoft invented a great many things, DHTML Behaviors(userData). UserData allows 64 KB per domain. ● In 2002, Adobe introduced flash cookies in flash environment, properly known as Local Shared Object allows upto 100 KB of data per domain. ● Brad Neuberg developed an early prototype of a Flash to-JavaScript bridge called AMASS (AJAX Massive Storage System), but it was limited by some of Flash’s design quirks.
  • 11. Presenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod Mohan Before HTML5 continued ● By 2006, with the advent of ExternalInterface in Flash 8, accessing LSOs from JavaScript became an order of magnitude easier and faster. ● Brad rewrote AMASS and integrated it into the popular Dojo Toolkit under the moniker dojox.storage. Flash gives each domain 100 KB of storage “for free”. ● In 2007, Google launched Gears, provided an API to an embedded SQL database based on SQLite.
  • 12. Presenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod Mohan Web Storage types Web Storage comes in two flavours and both uses the Key-value pair combination, 1. Local Storage, Exists untill it is removed or expired and available across multiple tabs 2. Session Storage, Once the window or tab is closed, the data stored is erased.
  • 13. Presenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod Mohan Web Storage Strengths ● The ease of use for developers: It has a simple AOI to get and set key/value pairs and can do much more. ● The amount of space provided: no less than 5 or 10 MB per domain. ● The LocalStorage object stores data with no expiration. ● Clent- Side Access: Servers cannot directly write into web storage. ● Data transmission: Objects are not sent automatically with each request but must be requested.
  • 14. Presenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod Mohan Web Storage Weaknesses ● Data is stored as a simple string. ● It has default 5 MB limit; more storage can be allowed by user if required. ● It can be disabled by the user or systems administrator. ● Storage can be slow with complex sets of data
  • 15. Presenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod Mohan Web Storage APIs ● setItem(Key, Value) – Adds an item to storage ● getItem(Key) - Retrives an item from storage ● removeItem(Key) – Removes an item from storage ● Clear() - Removes all items from storage ● key(n) - Returns the name of the key for the index provided ● Length - Number of key/value pairs in the storage list
  • 16. Presenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod Mohan How to check browser supports or not? // is localStorage available? if (typeof window.localStorage != "undefined") { alert(“Storage is working.”); } else { alert(“Storage is not working.”) } You can download JS at http://modernizr.com/
  • 17. Presenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod Mohan Working of setItem(key, value) // is localStorage available? if (typeof window.localStorage != "undefined") { // Local storage localStorage.setItem("hello", "Hello World!"); //Session storage sessionStorage.setItem("hello", "Hello World!"); } else { alert(“Storage is not working.”) }
  • 18. Presenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod Mohan Working of getItem(key) // is localStorage available? if (typeof window.localStorage != "undefined") { // Local storage var local = localStorage.getItem("hello"); alert(hello + “from Local Storage”); //Session storage var session = sessionStorage.setItem("hello"); alert(hello + “from Session Storage”); } else { alert(“Storage is not working.”) }
  • 19. Presenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod Mohan Working of removeItem(key) // is localStorage available? if (typeof window.localStorage != "undefined") { // Local storage localStorage.removeItem("hello"); //Session storage sessionStorage.removeItem("hello"); } else { alert(“Storage is not working.”) }
  • 20. Presenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod Mohan Working of clear, key & Length //to clear all localStorage.clear(); //to read all for (var i = 0; i < localStorage.length; i++) { var key = localStorage.key(i); var data = localStorage[key]; console.log(data); }
  • 21. Presenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod Mohan Storage Event ● When ever we store data in local storage, event is fired in other windows/tabs ● This event can be used to synchronice the data in defferent tabs Syntax: window.addEventListener('storage', function(event) { console.log('The value for '+event.key+' changes from '+event.oldValue+' to '+event.newValue); }) ; Presenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod Mohan Storage Event ● When ever we store data in local storage, event is fired in other windows/tabs ● This event can be used to synchronice the data in defferent tabs Syntax: window.addEventListener('storage', function(event) { console.log('The value for '+event.key+' changes from '+event.oldValue+' to '+event.newValue); }) ;
  • 22. Presenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod Mohan References Presenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod Mohan ● http://www.sitepoint.com/html5-web-storage ● http://www.html5rocks.com/en/features/storage ● http://diveintohtml5.info/storage.html Examples: ● http://www.ellipsetours.com/Demos/storage/ ● http://html5demos.com/storage
  • 23. Presenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod Mohan
  • 24. Presenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod Mohan Thank You Email: vinodm@mindfiresolutions.com, Skype: mfsi_vinodm, Mob No: +91 – 9620453625. Presenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod MohanPresenter: Vinod Mohan