在我更新 Angular 4 PWA 应用程序并部署后,用户无法获得新的更新,直到用户清除缓存并刷新浏览器。
Sw不更新。
即使我按下 crome Dev 中的更新按钮,它也不会更新,我必须清除缓存并刷新浏览器。
我用过这些包
@Angular/service-worker @Angular/platform-server ng-pwa-tools
确保您的应用程序检查更新从服务器时不时地.
In the app.component.ts
add 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);
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)