workbox
workbox copied to clipboard
Avoid precaching newer contents for old revisions
Library Affected: workbox-sw
Browser & Platform: Google Chrome 120.0.6099.129
Issue or Feature Request Description:
During deployment, clients can install a service worker and send requests to servers to precache assets.
At this point, the server responds with newer content, and the service worker should not store the content in CacheStorage as it is requesting content for an old revision.
Reproducible repository: https://github.com/iendeavor/workbox-issue-precaching
- client visits website and starts to register service worker
- service worker performs precaching for
{url: 'public/a.js', 'revision': 'version-1.js'} - (deploy new content: content of
public/a.jsis changed now, new metadata is{url: 'public/a.js', 'revision': 'version-2.js'}) - server responds newer content
- service worker save newer content for older revision