The size of Local Storage is limit to 5M, and is there any limit of Cache Storage when I used in Service Worker?
问题:
回答1:
As of Aug 15 2016, Addy Osmani posted:
How much can you store? In Chrome and Opera: Your storage is per origin (rather than per API). Both storage mechanisms will store data until the browser quota is reached. Apps can check how much quota they’re using with the Quota Management API. Firefox: no limits, but will prompt after 50MB data stored. Mobile Safari: 50MB max, Desktop Safari: unlimited (prompts after 5MB), IE10+ maxes at 250MB and prompts at 10MB. PouchDB track IDB storage behavior. Future facing: For apps requiring more persistent storage, see the on-going work on Durable Storage.
Where per origin means that API's like localStorage would be sharing storage space with API's like the service worker Cache.
回答2:
The short answer is that it will be browser specific and as of now (August 30, 2016) most browsers haven't started support.
The long answer is that the Cache, provided for in the Service Workers spec is still a working draft. Check out w3 org service-worker spec for more info if interested:
https://www.w3.org/TR/service-workers/
The following, per Mozilla's documentation, lists browser compatibility with service workers as well as Cache API.
Web/API/Caches
https://developer.mozilla.org/en-US/docs/Web/API/Cache#Browser_compatibility
Service Worker API
https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker#Browser_compatibility
As more browsers support these APIs, it will be easier to chart browser implementation to cache limitation to correctly address your question. I encourage others to improve this answer as developments occur.
For the time being Jake Archibald -- an editor of the service worker spec -- has provided the following site to help monitor and inform developers of readiness of service workers, including caches in various browsers:
Is Service Worker Ready?
Hope this helps
回答3:
It depends on the end browser. Chrome allows you to ask for unlimited storage (limited by the users hard drive size online), by default it is 5 MB. Safari and Firefox both default to unlimited cache. Mobile devices are again different Chrome (Android) in the mobile defaults to unlimited while safari (iOS) limits to 10MB.
Source