Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Different types of browser storage

From this slideshow http://slides.html5rocks.com/#slide8 and from Chrome: View > Developer > Developer Tools > Storage tab,

I learned that there are at least 4 types of browser storage: Databases, Local Storage, Session Storage, Cookies (are there more?)

What are the differences? When should I use one over the other?

For example, if a site wants to store user preferences, which storage method should the site tell the browser to use?

like image 913
ma11hew28 Avatar asked Oct 03 '10 02:10

ma11hew28


People also ask

What are different ways to store data in browser?

The 3 ways to store data in the browser are Cookies, Local Storage, and Session Storage. Depending on the needs any one of them is used to store data in the browser. In today's article, we will discuss an in-depth comparison between local storage, session storage, and cookies.

What are 3 categories of local storage?

Local Storage includes physical hardware such as external hard drives, flash drives, and CDs. As its name suggests, local storage is kept nearby. Here are several pros and cons of using local storage.


2 Answers

They are all browser-side storage to provide offline/cache mechanisms to web apps/sites:

  • local storage : simple key-value storage, the data is always stored as strings. The same data is accessible to all the pages of the domain and remains persistent even after you closed the browser.
  • session storage : same but is local to one URL and to one browser session (deleted on browser close).
  • SQL database (aka WebSQL): storage in a local DB you can access by SQL requests... seems already deprecated as IE and Firefox have stated they won't implement it.

Maybe you'll also hear soon about IndexedDB (now supported on IE 10, FF, and Chrome) which is a kind of local/sessionStorage but which you can use to store javascripts objects instead of only strings.

like image 97
Jocelyn delalande Avatar answered Sep 19 '22 04:09

Jocelyn delalande


The thing you are asking is about the Web Storage which is basically an HTML Web Storage. Local Storage- Used as a volatile storage (has no expiry) Session Storage - Till a session is being used or a tab is open IndexedDb - Once used, you have to manually clear it (History or going in Storage) WebSQL - Old but still used the same SQL queries - It's not a part of HTML5 specification now. Cookies - Are the most common to save small about of data, They are used by all the website and these days they every website using it should ask for user permissions. That's GDPR BTW!

Image from Chrome Developer Tools

like image 21
Ravindra Pawaskar Avatar answered Sep 17 '22 04:09

Ravindra Pawaskar