[Angular] Freshness Caching Policy

In some cases, you want to get fresh data instead of cache data to the screen, such as stock applications.

Only fallback to cache data if cannot get response from API, we can aslo add timeout for example 10s. 

{
  "index": "/index.html",
  "assetGroups": [{
    "name": "app",
    "installMode": "prefetch",
    "resources": {
      "files": [
        "/favicon.ico",
        "/index.html"
      ],
      "versionedFiles": [
        "/*.bundle.css",
        "/*.bundle.js",
        "/*.chunk.js"
      ]
    }
  }, {
    "name": "assets",
    "installMode": "lazy",
    "updateMode": "prefetch",
    "resources": {
      "files": [
        "/assets/**"
      ]
    }
  }],
  "dataGroups": [
    {
      "name": "lessons-api",
      "urls": [
        "/api/lessons"
      ],
      "cacheConfig": {
        "strategy": "freshness",
        "timeout":"10s",
        "maxAge": "1d",
        "maxSize": 100
      }
    }
  ]
}
原文地址:https://www.cnblogs.com/Answer1215/p/8879054.html