-
Notifications
You must be signed in to change notification settings - Fork 12
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
Add API methods for cache storage #7
base: main
Are you sure you want to change the base?
Conversation
this is really interesting, thank you! I am curious about the choice to store all the data in a single cache entry, instead of a single cache entry per "key" in the store. What are your thoughts on the tradeoffs here? |
Thank you! I think that storing all the data in a single cache entry may allow for lower overhead since metadata is stored per cache entry. On the other hand having a single cache entry store one key-value pair may support more concurrency with Independent updates being safer and easier to manage? I primarily wanted to isolate all of data manually added to cache from any caching done by the websites by creating a separate "generic-key-value-cache" to store all the manual data. |
Yeah, I see that reasoning, and agree with the observations. For comparison:
So, in summary, all the existing adapters basically store entries separately (with the slight technical exception of This would make But to state other tradeoffs explicitly:
One option might be to store each key-val pair as separate cache entries, but to have a naming prefix that sort of keeps all of them sorted together... like |
Yeah I agree. I just updated I had the cache entries be prefixed with On your point about expiration/eviction of manually created cache entries, there doesn't seem to be a default expiration unless manually set in the header (i.e. I'm not sure if storing key-value pairs in separate cache entries would make it any more or less subject to eviction. But per https://developer.mozilla.org/en-US/docs/Web/API/Storage_API/Storage_quotas_and_eviction_criteria#how_is_data_evicted, "When an origin's data is evicted by the browser, all of its data, not parts of it, is deleted at the same time. If the origin had stored data by using IndexedDB and the Cache API for example, then both types of data are deleted." |
No description provided.