basket.js icon indicating copy to clipboard operation
basket.js copied to clipboard

Usage in Private Browsing mode

Open jonscottclark opened this issue 8 years ago • 1 comments

While debugging a site in iOS I saw that my home-baked localStorage caching script was failing in private mode:

QuotaExceededError: DOM exception 22: An attempt was made to add something to storage that exceeded the quota

I see that you check for this error here: https://github.com/addyosmani/basket.js/blob/gh-pages/lib/basket.js#L15 — could you explain for the layman what's happening here and how basket.js handles caching of resources during private browsing (if at all)?

jonscottclark avatar Jul 19 '16 19:07 jonscottclark

The referenced code sorts all localStarage items managed by basket.js and removes the oldest entry (recursively, until no error is thrown). Private mode in Safari hower, throws the QuotaExceededError when accessing localStorage, so it can't store anything. MDN gives an example how to handle this.

hermansje avatar Jul 22 '16 22:07 hermansje