I have a PWA that needs to download map data before going offline. I have created a data group to cache those resources with the NGSW, and I have created an initialization process to fetch all data that will be required when offline. The dataGroup
definition is as follows
{
"name": "map",
"urls": ["/map-api/**"],
"cacheConfig": {
"maxSize": 10000,
"maxAge": "365d"
}
}
thus the cache named ngsw:/:1:data:dynamic:map:cache
is used. I have noticed, however, that whenever I update the app, the cache is deleted and then recreated.
I am not entirely sure why this happens (could be the browser clearing up space), I have not found any traces of this documented, but I have found two functions in the NGSW code that can do that. Is there a way to prevent this from happening? Is it behavior by design?