If you want to cache API response by using angular service-worker, you can do it in:
src/ngsw-config.json:
{ "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/**" ] } }], // cache for API data "dataGroups": [ { "name": "lessons-api", "urls": [ "/api/lessons" ], "cacheConfig": { "strategy": "performance", // cache first, network last "maxAge": "1d", "maxSize": 100 } } ] }
本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系我们删除。