问题
The Cache-Control
header setting in my firebase.json file does not seem to be working. I have set the max-age
value, for all files, to 31536000
(1 year). My firebase.json file is-
{
"hosting": {
"public": "public"
},
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
],
"headers": [{
"source": "**",
"headers": [{
"key": "Cache-Control",
"value": "max-age=31536000"
}]
}]
}
The file seems to abide by the firebase documentation.
But the max-age
value, for all files, is still set to the browser default of 3600
(1 hour).
回答1:
According to full page configuration you have to set hosting key first.
This have to work:
{
"hosting": {
"public": "app",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
],
"headers": [{
"source" : "**",
"headers" : [{
"key" : "Cache-Control",
"value" : "max-age=31536000"
}]
}]
}
}
来源:https://stackoverflow.com/questions/38114755/cache-control-header-in-firebase-json-file-not-working