I use Angular 5.1 with the internal Service Worker This is my ngsw-config.json file :
{
"appData": "Angular 5.1",
"index": "/index.html",
"assetGroups": [
{
"name": "app",
"installMode": "prefetch",
"resources": {
"files": ["/favicon.ico", "/index.html"],
"versionedFiles": ["/*.bundle.css", "/*.bundle.js", "/*.chunk.js"]
}
},
{
"name": "assets",
"installMode": "prefetch",
"updateMode": "prefetch",
"resources": {
"files": ["/assets/**"]
}
}
],
"dataGroups": [
{
"name": "tasks-users-api",
"urls": ["/api"],
"cacheConfig": {
"strategy": "freshness",
"maxSize": 20,
"maxAge": "1h",
"timeout": "5s"
}
}
]
}
In ngOnInit function of my homepage, I call the /api url listed in dataGroups. When I open my console, I can see this url is call (framed in red below) before the start of the service worker (I guess the start of the service worker matches with the element framed in blue below).
So, if I switch off my internet connection, the /api call isn't handle by the service worker. If I navigate on another page and come back to the homepage before switch off my connection, the /api call is handle by service worker.
Is this an issue ? How to handle the case ?
