Is there any way to force users to reload my web application and get around local service worker, maybe via some configuration on my webserver (nginx) or any other means?
Background:
I have a bit of a problem: I have an angular application with service worker, that is already cached on peoples machines. The code below shows, how it checkes for updades, displays and update message and then does the update, once the update message is dismissed.
Unfortunately there is Bug in the update message (snackbarService.showVersionUpdate()
) that updates.activateUpdate()
is never called. So the old, cached frontend version is used until the browser window is closed and reopened or reloaded with Ctrl+F5.
The problem is, all fixes to the code only come into effect after an update of the service worker, which itself is the problem.
constructor(updates: SwUpdate, snackbarService: SnackbarService) {
updates.checkForUpdate();
updates.available.subscribe(event => {
// Show snackbar
const snackBar = snackbarService.showVersionUpdate();
snackBar.afterDismissed().subscribe(() => {
updates.activateUpdate().then(() => {
window.location.reload();
});
});
});
}
I am grateful for any solutions or ideas!
Edit: I found this answer, which talks about updating the service worker itself. Does anyone know how to do that with the angular service worker?