在我更新我的 Angular 4 PWA 应用程序并部署之后,在用户清除缓存并刷新浏览器之前,用户不会获得新的更新。 Sw不更新。 即使我在 crome Dev 中按下更新按钮,它也不会更新,我必须清除缓存并刷新浏览器。
我用过这些包 @angular/service-worker @angular/platform-server ng-pwa-tools
最佳答案
确保您的应用不时地从服务器检查更新。
在 app.component.ts
中,将 private swUpdate: SwUpdate
添加到构造函数中。
this.swUpdate.available.subscribe(event => {
if (confirm('Update Available. Refresh the page now to update the cache.')) {
location.reload(true);
} else {
console.log('continue with the older version');
}
});
setInterval(() => {
this.swUpdate.checkForUpdate();
}, 21600);
关于javascript - Angular 4 PWA Service Worker 在有新更新可用时不会更新,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46179907/