Here is the scenario:
You have a site that currently cached via a SW. You deploy a new version that includes an updated SW with a cache busting version. The company then announces the new features. People visit the site, however, even though the SW busts it still serves up the previous cache while updating its cache in the background. So visitors that come for the new features don't see them.
Is this the expected experience with ServiceWorkers? What are the recommended strategies to get around this?
To bypass the service worker, set ngsw-bypass as a request header, or as a query parameter. The value of the header or query parameter is ignored and can be empty or omitted.
Open the app in your browser (http://localhost:8443/). Turn off “Update on reload” if it is on (see “Service Worker Lifecycle”). Delete all existing service workers registered to this page. In Chrome, this can be achieved by using the “Clear storage” tool in the Application panel of the developer tools.
Note that this is NOT the Cache folder. It's the Cache of Service Worker, the path should be AppData\Local\Microsoft\Edge\User Data\Default\Service Worker .
Caching unnecessary resources wastes bandwidth and storage space and could cause your app to serve unintended outdated resources. You don't need to cache all the assets at once, you can cache assets many times during the lifecycle of your PWA, such as: On installation of the service worker. After the first page load.
It's the expected behavior whenever you serve resources with a cache-first strategy, yes.
There are two options:
sw-precache
), then you can detect these updates by listening for specific service worker controller events, and use those to trigger the message. (Here's an example.)If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With