javascriptangularjschrome-web-store

What happens when local / Session Storage is full?


I know its near to impossible but I have a question in my mind.

what will be the behavior of the web application if all the web storage(local / session) is full in angular web app ?

Does it effect the performance of the web app ? if yes then how it will effect ?

how the application will react in the following browsers chrome, firefox and Opera ?

I'm reading a blog which discuss the session and local storage but i did't find my Answer there. (https://krishankantsinghal.medium.com/local-storage-vs-session-storage-vs-cookie-22655ff75a8)


Solution

  • If storage is full when you try to add something to it, according to the specification the method that's adding the new/updated item must throw a QuotaExceededError. So your app/page will work just fine if storage is full but if it tries to add anything, that action will fail with an error.

    From that link:

    The setItem(key, value) method must first check if a key/value pair with the given key already exists in the list associated with the object.

    If it does not, then a new key/value pair must be added to the list, with the given key and with its value set to value.

    If the given key does exist in the list, and its value is not equal to value, then it must have its value updated to value. If its previous value is equal to value, then the method must do nothing.

    If it couldn't set the new value, the method must throw a QuotaExceededError exception. (Setting could fail if, e.g., the user has disabled storage for the site, or if the quota has been exceeded.)

    (my emphasis)