Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between local storage and cache in the browser? [closed]

When we open application segment in the developer console of chrome, we see many things like:

  • Application

    • Manifest
    • service Workers
  • Storage

    • local storage
    • session storage
    • indexed db
    • Web sql
    • Cookies
  • Cache

    • Cache Storage
    • Application Cache

I know that cache is used for saving the resource locally and cookies are for saving the data in the client side for maintaining the session. Cache stores in key value format.

I want to know exactly what the difference is between them.

like image 443
Ajender Reddy Avatar asked Apr 20 '17 12:04

Ajender Reddy


People also ask

Is local storage deleted when browser closed?

localStorage is similar to sessionStorage , except that while localStorage data has no expiration time, sessionStorage data gets cleared when the page session ends — that is, when the page is closed.

What is the difference between storage and cache?

Cache is distinguished by being an ephemeral copy of a relatively small amount of currently in-use data for rapid access or to buffer writes. Storage, by contrast, sits behind/below cache and provides the bulk, long term retention location for data and is addressed in blocks rather than bytes.

Does clearing browser cache clear local storage?

Local Storage data will not get cleared even if you close the browser. Because it's stored on your browser cache in your machine. Local Storage data will only be cleared when you clear the browser cache using Control + Shift + Delete or Command + Shift + Delete (Mac)

Is cache stored in local storage?

Caching refers to storing information locally to speed communication between a client such as a web browser and a server such as a web server. The cache can be located on the client side, the server side, or – as is often the case – both.


1 Answers

I have limited experience, but for what I can understand:

Cache is data which is used very frequently, so it is stored to reduce processing and loading required.

  1. In a computer, the cache is what helps to hold temporary data used by the processor to compute the most basic instructions. It is a lot faster, therefore, more expensive/smaller than ram, but same ideology.
  2. On your browser that frequent data are files like the HTML and CSS you get from a web page

Local Storage instead, is data little less generic and a little more user specific, like a form info or your already viewed pages that appear on purple at Google It is also the objects and data your CSS and HTML renders.

For example: on YouTube, you have a standard format in which information, icons, and toolbars are displayed, imagine this as the interface. Cache helps a lot here. That is why you can search for new videos without having to wait for YouTube icon, search bar, etc... to reload again.

On the other hand, When you log in to youtube or any other web page like Amazon, That site knows your id by the local storage. Local storage also has different javascript interface objects like some tabs or extra menus.

Sources:

  • HTML5 Local Storage VS App Cache Offline Website Browsing
  • http://searchstorage.techtarget.com/definition/cache
  • http://www.differencebetween.com/difference-between-ram-and-vs-cache-memory/

  • I also went and tried myself the following: I went to my browser settings and deleted cache data and the page refreshed. Then I cleared Local Storage and I had to log in again.

like image 122
Rodrigo Mendoza Avatar answered Sep 28 '22 09:09

Rodrigo Mendoza