gpt4 book ai didi

javascript - Angular 4 PWA Service Worker 在有新更新可用时不会更新

转载 作者:太空狗 更新时间:2023-10-29 18:30:38 30 4
gpt4 key购买 nike

在我更新我的 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/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com