Issue
I have an ionic 4 app hosted on firebase and when I push an update, my users have to clear their cache to load the newest version of the app.
I've searched around a bit and modified my firebase.json
to reflect the following:
{
"hosting": {
"public": "www",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
],
"headers": [
{ "source":"/service-worker.js", "headers": [{"key": "Cache-Control", "value": "no-cache"}] }
],
"rewrites": [
{
"source": "**",
"destination": "/index.html"
}
]
}
}
I thought this worked, but today I pushed an update and it required me to clear my cache. Does anyone have other ideas on how to force an update?
Solution
Try changing this
"headers": [{"key": "Cache-Control", "value": "no-cache"}]
to this
"headers": [{"key": "Cache-Control", "value": "no-cache, no-store, must-revalidate"]
Or this
"headers": [{"key": "Cache-Control", "value": "public, max-age=0"}]
Also, you are setting the rule for "source" : "/service-worker.js"
, is that what you want?
I think you want this :
"headers": [
{
"source": "/**",
"headers": [
{
"key": "Cache-Control",
"value": "no-cache, no-store, must-revalidate"
}
]
}]
See what they do in this answer
This could reduce performances for the users
Answered By - BorisD
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.