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

The Cache objects do not expire unless authors *or users* delete the entries. #1276

Open
bsittler opened this issue Feb 3, 2018 · 6 comments

Comments

@bsittler
Copy link

bsittler commented Feb 3, 2018

https://w3c.github.io/ServiceWorker/#cache-lifetimes says:

The Cache objects do not expire unless authors delete the entries.

I propose to extend this to allow the possibility of the user deleting caches and individual cache entries. While I don't think this is likely to be common, it does mean the cache storage mechanism has weaker overall consistency guarantees than are otherwise implied:

The Cache objects do not expire unless authors or users delete the entries.

This might be understood to mean that developers can rely on end-users not being able to modify cache contents — at least, not without running code using the developer tools or an equivalent mechanism. However, at least in Chrome, caches can also be manually removed by the user (for instance, to reduce exposure to privacy risks or to reclaim storage space) without necessarily stopping the origin's Service Workers or removing the origin's Service Workers or other storage.

For instance, using:

Settings > Advanced > Privacy & Security > Content settings > Cookies > See all cookies and site data > [hostname] > Cache Storage > X

... the user can remove all caches for an origin. Those caches are also removable using the developer tools, but given the intended audience I think it's less clear that that disagrees with the wording of the spec. That part is in:

Developer Tools > Application > Clear storage > [uncheck all but "Cache storage"], Clear site data

The developer tools also allow an individual cache or cache entry to be selected and deleted using the "Cache" tree in the side-navigation area.

+@inexorabletash

@bsittler
Copy link
Author

bsittler commented Feb 3, 2018

Note that the separate possibility for user agent clearing of caches after author opt-in is already proposed in the semi-related #863 - however I don't think there is any dependency relationship between the two proposals as the actor is distinct, and for a user agent acting on the user's behalf in the course of carrying out the user's specific instruction to delete caches or cache entries I don't think requiring opt-in is reasonable

edit: this came up while discussing more immediately effective UI-initiated cache deletion in cases where outstanding cache handles remain open in still-running scripts https://crbug.com/795701#c30

@jakearchibald
Copy link
Contributor

This seems a little nit-picky. When you use developer tools, isn't it assumed you're operating at a privilege greater than the author? Eg, if CSP has blocked eval, the devtools console still works.

@mfalken
Copy link
Member

mfalken commented Mar 8, 2018

Doesn't the browser also delete the Cache if it needs to free up storage space?

@jakearchibald
Copy link
Contributor

@mattto the cache API is part of origin storage. The browser may purge origin storage, but it shouldn't delete individual caches or cache items any more than it should remove entries/stores from indexeddb.

@Ryandev
Copy link

Ryandev commented Feb 25, 2022

Is there a use case for supporting the Expires or Cache-Control headers or setting expiration against the CacheStorage API

Our use-case is currently PWA Audio tours which can contain >1gb of cache controlled content & if the user leaves the page without requesting the PWA to delete any content, then according to the spec that space persists & the browser will not remove this.

Having some eviction criteria against the CacheStorage would allow the browser to remove Cache Responses in the absence of the service-worker

@inexorabletash
Copy link
Member

Having eviction priorities and/or expiration policies has been discussed as a potential feature of storage buckets, which would extend this beyond the Cache API.

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

5 participants