Reputation: 402
I have a web app using custom domain. This domain has A record mapped to 151.101.1.195 and 151.101.65.195.
Everything works correctly, but when I have firebase.json like this:
{
"hosting": {
"public": "dist",
"headers": [{
"source": "**/*.html",
"headers": [{
"key": "Cache-Control",
"value": "private, max-age=0, no-cache"
}]
}]
}
}
I still see the response headers like this when I visit https://mycustomdomain.com:
accept-ranges:bytes
cache-control:max-age=3600
content-encoding:gzip
content-length:839
content-type:text/html; charset=utf-8
date:Wed, 27 Sep 2017 06:54:58 GMT
etag:"f0b36e6c2a348eb46d07907fea856e9a"
last-modified:Wed, 27 Sep 2017 06:53:07 GMT
server:nginx
status:200
strict-transport-security:max-age=31556926
vary:Accept-Encoding
via:1.1 varnish
x-cache:HIT
x-cache-hits:2
x-powered-by:Express
x-served-by:cache-bma7024-BMA
x-timer:S1506495298.256593,VS0,VE0
I expect the cache control header to be modified, but it doesn't change.
How can I change the response headers for domain root?
Upvotes: 4
Views: 747
Reputation: 402
For anyone looking, I ended up doing it like this, and it seems to work:
{
"hosting": {
"public": "dist",
"headers": [
{
"source": "/",
"headers": [{
"key": "Cache-Control",
"value": "private, max-age=0, no-cache"
}]
},
{
"source": "**/*",
"headers": [{
"key": "Cache-Control",
"value": "private, max-age=0, no-cache"
}]
},
{
"source": "**/*.js",
"headers": [{
"key": "Cache-Control",
"value": "max-age=31536000"
}]
},
{
"source": "**/*.css",
"headers": [{
"key": "Cache-Control",
"value": "max-age=31536000"
}]
},
{
"source": "**/*.jpg",
"headers": [{
"key": "Cache-Control",
"value": "max-age=31536000"
}]
},
{
"source": "**/*.png",
"headers": [{
"key": "Cache-Control",
"value": "max-age=31536000"
}]
}
],
"rewrites": [
{ "source": "/api/1/mina", "function": "mydata" },
{ "source": "**", "destination": "/index.html" }
]
}
}
This also works with functions. Note that .js files are also agressively cached, as we use cache busting urls.
Upvotes: 1