question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ng service-worker does not cache data

See original GitHub issue

ng service-worker caches data only for the time specified in the Cache-Control response header: public, max-age = 60, s-maxage = 60. After 60 seconds in offline mode, the response 504 Gateway Timeout (from ServiceWorker) comes to the request.

 {
      "$schema": "./node_modules/@angular/service-worker/config/schema.json",
      "index": "/index.html",
      "assetGroups": [
        {
          "name": "app",
          "installMode": "prefetch",
          "resources": {
            "files": [
              "/favicon.ico",
              "/index.html",
              "/manifest.webmanifest",
              "/*.css",
              "/*.js"
            ]
          }
        },
         {
          "name": "assets",
          "installMode": "lazy",
          "updateMode": "prefetch",
          "resources": {
            "files": [
              "/assets/**",
              "/app/app.component.ts",
              "/*.(pdf|odt|eot|svg|cur|jpg|png|webp|gif|otf|ttf|woff|woff2|ani)"
            ]
          }
        }
      ],
      "dataGroups": [
      {
          "name": "github-api",
          "urls": ["**//api.github.com/**"],
          "cacheConfig": {
          "strategy": "performance",
          "maxSize": "100",
          "maxAge": "7d"

        }
      }
    ]
    }

What could be the problem?

P.S. I installed the worker for my application using this command: ng add @angular/pwa --project project-name –

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:14 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
postnikovpashacommented, Dec 10, 2019

Thanks so much for the consultation! (‘ngsw-bypass’, ‘true’) is exactly what I need!

0reactions
angular-automatic-lock-bot[bot]commented, Jan 10, 2020

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Angular service worker doesn't cache assets once deployed ...
Even though the scope path seems being correct and the app is installable, the service worker does not caches the assets nor the...
Read more >
Angular PWA service worker doesn't cache every resource ...
It looks like what is happening is that, on first load, the browser is getting the core assets and putting them in the...
Read more >
Service worker configuration - Angular
Does not cache any of the resources up front. Instead, the Angular service worker only caches resources for which it receives requests. This...
Read more >
Caching HTTP Requests in Angular using Service Workers
This json currently has no configuration for caching http requests. It needs to be noted that only non-mutating http requests like GET and...
Read more >
Angular Service Worker - Step-By-Step Guide
This is a Javascript-based key/value caching mechanism that is not related to the standard browser Cache-Control mechanism, and the two ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found