0

I have been trying to implement angular PWA and have setup the config file as below:

    {
  "index": "/index.html",
  "assetGroups": [
    {
      "name": "app",
      "installMode": "prefetch",
      "resources": {
        "files": [
          "/favicon.ico",
          "/index.html",
          "/manifest.webmanifest",
          "/*.css",
          "/*.js"
        ]
      }
    },
    {
      "name": "assets",
      "installMode": "prefetch",
      "updateMode": "prefetch",
      "resources": {
        "files": [
          "/assets/**",
          "/*.(eot|cur|jpg|png|webp|gif|otf|ttf|woff|woff2|ani|html)"
        ]
      }
    }
  ],
  "dataGroups": [
    {
      "name": "api-performance",
      "urls": [
        "/Languages"
      ],
      "cacheConfig": {
        "strategy": "freshness",
        "maxSize": 500,
        "maxAge": "3d"
      }
    }
  ]
}

In the config I have set so that the whole assets folder is pre-fetched for offline use. It is working as expected but now I want to show a loader or status to inform the users that all the data required for the offline use has not been completely prepared and they need to wait.

Is there any way to figure out if the prefetch process has started/ended or anything that might help us to know about the status of prefetched items.

Atul Stha
  • 1,404
  • 8
  • 23
  • 46
  • Does this answer your question? [Trigger event when serviceworker finished fetching new files?](https://stackoverflow.com/questions/60402086/trigger-event-when-serviceworker-finished-fetching-new-files) – PeterS Oct 27 '21 at 11:33
  • Not quite. The solution provided seems to be related to the fetching of a new updated package rather than fetching assets after the initialization of a new version of the app. – Atul Stha Oct 28 '21 at 10:44
  • 1
    The only way then would be to alter the ngsw-worker.js code so that it notifies something, either by way of cookie or server call that the prefetch has been successful. If you look at the fetchAndCacheOnce method in the file this will be the place to update a flag when done. – PeterS Oct 29 '21 at 13:39

0 Answers0