Backing Out of Bswup
Fully remove Bswup from a deployed app - dropping offline support, or recovering clients stuck on a broken worker or cache - with the self-destructing cleanup worker.
Replace the content of your service-worker.js and
service-worker.published.js (the file deployed builds actually ship, via the
ServiceWorker item's PublishedContent mapping) with:
self.importScripts('_content/Bit.Bswup/bit-bswup.sw-cleanup.js');What happens next
On its next update check, every client installs this self-destructing worker instead. It:
- activates immediately,
- purges this app's Bswup and Blazor caches,
- unregisters its own registration, and
- signals open tabs to detach.
Tabs the previous worker controlled reload once; everything afterwards runs purely from the network,
even while the page keeps referencing bit-bswup.js - each later load just repeats the
register/self-unregister cycle silently, with no reloads.
bit-bswup.js script tag can be removed from the host document too.
Client-side reset without backing out
If you only need to recover a single broken client (not remove Bswup from the deployment),
prefer BitBswup.forceRefresh() - it clears this
app's caches, unregisters its worker, and reloads, without touching the deployed service worker file.