0

I'm trying to solve an issue with Angular (14) and the service worker, that is constantly fetching some answer in the cache rather than querying from backend api for a set of routes, although these routes are listed in my ngsw-config.json in a dataGroup as shown here:

 "name": "data",
 "cacheConfig": {
        "strategy": "freshness",
        "maxAge": "0s",
        "maxSize": 10,
        "timeout": "1s"
      },
      "urls": [
        ...,
        "/api/equipments/**"
      ]
   }

with this config, I see that GET /api/equipments/4 for example is fetched from cache. My problem is that the data can be frequently updated, so I need it to be refreshed as often as possible. Shouldn't this configuration make the data to be refreshed as often as possible?

user7330689
  • 21
  • 1
  • 2

1 Answers1

0

timeout attribute corresponds is "how long the Angular service worker will wait for the network to respond before using a cached response" - angular team comment

You should increase this value to make sure you're not using cached response

PasNinii
  • 634
  • 8
  • 18
  • Hi and thanks for your answer! I tried several values for this parameter, with the same result. GET queries are instant, (ie, far less than 1s with the current parameter), which let me think that this parameter (at least) is not taken into account. – user7330689 May 17 '23 at 13:37