cordova-docs icon indicating copy to clipboard operation
cordova-docs copied to clipboard

Cache storage documentation

Open mfulton26 opened this issue 4 years ago • 5 comments

Feature Request

Details on advantages/disadvantages, supported platforms, etc. for the Cache API supported by browsers, etc.

Motivation Behind Feature

Cordova has some great docs for helping when making decisions on where and how to store data but doesn't currently provide information saved about the Cache API which can be used in some cases instead of IndexedDB. Documenting this will help folks make informed decisions.

Feature Description

Document Cache API similar to how localStorage, IndexedDb, Web SQL, etc. are documented.

www/docs/en/dev/cordova/storage/storage.md

Alternatives or Workarounds

Various sites out there have some information about total size limits on iOS, etc. etc. but it is hard to find what applies to apps running inside Cordova/WKWebView.

mfulton26 avatar Oct 08 '21 11:10 mfulton26

Based on MDN, it looks like the Cache API is a service worker feature. I'm pretty sure service workers are not supported by the underlying webviews. They are supported in the browser application themselves (e.g. Safari and Chrome) but not the WKWebView / Android System Webview counterpart in which the native apps have access to.

breautek avatar Oct 08 '21 12:10 breautek

Although caches was introduced with service workers it is available on the window object similar to indexedDb.

https://developer.mozilla.org/en-US/docs/Web/API/Window

mfulton26 avatar Oct 08 '21 12:10 mfulton26

Note that the Cache interface is exposed to windowed scopes as well as workers. You don't have to use it in conjunction with service workers, even though it is defined in the service worker spec.

mfulton26 avatar Oct 08 '21 12:10 mfulton26

Ah ok! Interesting. If that's the case I'd suspect it to work like the other web storage strategies. I think it should be tested though.

Various sites out there have some information about total size limits on iOS, etc. etc. but it is hard to find what applies to apps running inside Cordova/WKWebView.

I know in Chromium, the web storage quota is not constant. It's dynamic based on the total available disk space available on the device. On devices with large space (> 10GB if I recall) the quota is about 10%, otherwise it's some hard-coded value. It's not documented, but you can find the code in the chromium source code. Which also means these rules are subjected to change, as it's an implementation detail.

For iOS, I don't think there is any such code in the open source WebKit project -- but we do know there are limits. We just don't know how they decide those limits.

breautek avatar Oct 08 '21 13:10 breautek

Yes, if it could be tested and documented that would be very helpful for reference. Especially for iOS.

mfulton26 avatar Oct 08 '21 23:10 mfulton26