Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cache storage documentation #1210

Open
mfulton26 opened this issue Oct 8, 2021 · 5 comments
Open

Cache storage documentation #1210

mfulton26 opened this issue Oct 8, 2021 · 5 comments

Comments

@mfulton26
Copy link

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.

@breautek
Copy link
Contributor

breautek commented Oct 8, 2021

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.

@mfulton26
Copy link
Author

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
Copy link
Author

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.

@breautek
Copy link
Contributor

breautek commented Oct 8, 2021

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.

@mfulton26
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants