The Cache-Control
header in my firebase.json
does not seem to be working. The max-age
value for all files is set to 31536000
(1 year), but when loading the page it is still set to the browser default of 3600
(1 hour).
The firebase.json
file seems to abide by the firebase documentation.
{
"hosting": {
"public": "public"
},
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
],
"headers": [{
"source": "**",
"headers": [{
"key": "Cache-Control",
"value": "max-age=31536000"
}]
}]
}
Without the cache control header the browser requests the resource every time it loads a new(?) page.
If you want to enable Cache-Control for all files, add Header set line outside the filesMatch block. As you can see, we set the Cache-Control header's max-age to 3600 seconds and to public for the listed files.
Cache-control is an HTTP header used to specify browser caching policies in both client requests and server responses. Policies include how a resource is cached, where it's cached and its maximum age before expiring (i.e., time to live).
Firebase Hosting uses a powerful global CDN to make your site as fast as possible. Any requested static content is automatically cached on the CDN. If you redeploy your site's content, Firebase Hosting automatically clears all your cached static content across the CDN until the next request.
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"
}]
}]
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With