admin管理员组文章数量:1315369
After i update my Angular 4 PWA app and deployed , user not getting new updates until user clear the cache and refresh the browser. Sw doesn't update. Even i press the update button in crome Dev it doesn't update I have to clear the cache and refresh the browser.
I used these packages @angular/service-worker @angular/platform-server ng-pwa-tools
After i update my Angular 4 PWA app and deployed , user not getting new updates until user clear the cache and refresh the browser. Sw doesn't update. Even i press the update button in crome Dev it doesn't update I have to clear the cache and refresh the browser.
I used these packages @angular/service-worker @angular/platform-server ng-pwa-tools
Share Improve this question asked Sep 12, 2017 at 15:08 shashik thiwankashashik thiwanka 812 silver badges5 bronze badges 3- 2 Have you found a solution to this issue? I am having the same problem even with setting cache headers to not cache. – Dan Waterbly Commented Sep 15, 2017 at 21:10
- 2 No... I haven't if u using workbox 2 that's possible to do..i update sw manifest cache life to 0 .but still won't update.. – shashik thiwanka Commented Sep 17, 2017 at 2:29
- Same here, but I'm using angular 5 with the SW native from angular-cli. Have you find any solution? – Juan Sánchez Commented Jan 8, 2018 at 9:22
2 Answers
Reset to default 6Make sure your app checks for updates from the server from time to time.
In the app.ponent.ts
add private swUpdate: SwUpdate
into the constructor.
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);
Based on the information you've provided I guess your web server is serving the SW file with some caching headers and the visitors' browsers use the cached version.
Be sure to explicitly set the caching headers to no-cache/-1/etc. so that the browser always checks the web server for a new version of the service-worker.js (or whatever) file.
本文标签: javascriptAngular 4 PWA Service Worker doesn39t update when new updates availableStack Overflow
版权声明:本文标题:javascript - Angular 4 PWA Service Worker doesn't update when new updates available - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741975682a2408107.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论