workbox icon indicating copy to clipboard operation
workbox copied to clipboard

Avoid precaching newer contents for old revisions

Open soc221b opened this issue 2 years ago • 0 comments

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

  1. client visits website and starts to register service worker
  2. service worker performs precaching for {url: 'public/a.js', 'revision': 'version-1.js'}
  3. (deploy new content: content of public/a.js is changed now, new metadata is {url: 'public/a.js', 'revision': 'version-2.js'})
  4. server responds newer content
  5. service worker save newer content for older revision

soc221b avatar Jan 10 '24 08:01 soc221b