'How to stop downloading service worker cached resources on each & every page reload in Angular?

Every time the user refreshes the application, the Angular service worker checks for updates to the application by looking for updates to the ngsw.json manifest. If an update is found, it is downloaded and cached automatically, and will be served the next time the application is loaded.

There are 2 scenario

  • Scenario 1 - When user navigate from one page to another using navigation links(menu), then Angular won't download any cached files again from service worker, if it is cached already.
  • Scenario 2 - When user reload the page, then it will download the cached resources from service worker once again for each and every page reload/refresh.

There would be page loading time difference between page navigation & page reload. So how to eliminate downloading of cached resources from service worker again and again on page refresh/reload, If there are no updated version in ngsw.json manifest.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source