[Angular] Freshness Caching Policy - Network First, Cache Last


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 } } ]
}

 


注意!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系我们删除。



 
© 2014-2018 ITdaan.com 粤ICP备14056181号