I’m deploying an Angular 11 app to an Azure AppService. The app uses a Service Worker. My users are experiencing caching issues. I’ve fixed a lot of these by setting the cache control header on the index.html to no-cahce
, but they’re still experiencing issues. I think it’s down to the App not updating, so I’m wondering what cache-control headers the nsgw.json and manifest.webmanifest need to be served with? I can’t find any documentation about serving and angular app.
2
Answers
This is not a definitive answer, but a hint that might help you configure the caching behaviour of your app with service workers. in
ngsw-config.json
there is a property to control how to update the cached ressources. I do not see your file details but there should be"updateMode": "prefetch"
. This is where you control the behaviour of your cached ressources in your app. Read on Angular Docs the values that can be passed to theupdatedMode
. You can try to set theupdateMode
tolazy
.According to documentation,
lazy
:I could not find any documentation either while having a similar issue, so I checked what angular.io (also an Angular app itself) uses as
cache-control
:no-cache
ngsw.json
andpwa-manifest.json
havemax-age=3600
ngsw-worker.js
hasmax-age=86400
I’m no sure why
ngsw.json
is allowed to be cached, but otherwise these values seem reasonable.