Firebase 托管未获取到期 header
Expiration header is not picked up by Firebase Hosting
我的 firebase.json 文件如下所示:
{
"hosting": {
"public": "public",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
],
"headers": [{
"source": "**",
"headers": [{
"key": "Cache-Control",
"value": "max-age=960000"
}]
}],
"rewrites": [ {
"source": "**",
"destination": "/index.html"
}],
"source" : "404.html",
"headers" : [ {
"key" : "Cache-Control",
"value" : "max-age=960000"
}],
"headers": [ {
"source" : "**/*.@(eot|otf|ttf|ttc|woff|font.css)",
"headers" : [ {
"key" : "Access-Control-Allow-Origin",
"value" : "*"
} ]
}],
"cleanUrls": true,
"trailingSlash": false
}
}
现在在浏览器中检查资产,我看不出对发送的过期 headers 有任何影响。
请问有什么事吗?
您的配置格式不正确 -- 您的 hosting
配置中有多个顶级 headers
。它应该看起来更像:
{
"hosting": {
"public": "public",
"ignore": ["firebase.json", "**/.*", "**/node_modules/**"],
"headers": [
{
"source": "**",
"headers": [
{
"key": "Cache-Control",
"value": "max-age=960000"
}
]
},
{
"source": "404.html",
"headers": [
{
"key": "Cache-Control",
"value": "max-age=960000"
}
]
},
{
"source": "**/*.@(eot|otf|ttf|ttc|woff|font.css)",
"headers": [
{
"key": "Access-Control-Allow-Origin",
"value": "*"
}
]
}
],
"rewrites": [
{
"source": "**",
"destination": "/index.html"
}
],
"cleanUrls": true,
"trailingSlash": false
}
}
我的 firebase.json 文件如下所示:
{
"hosting": {
"public": "public",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
],
"headers": [{
"source": "**",
"headers": [{
"key": "Cache-Control",
"value": "max-age=960000"
}]
}],
"rewrites": [ {
"source": "**",
"destination": "/index.html"
}],
"source" : "404.html",
"headers" : [ {
"key" : "Cache-Control",
"value" : "max-age=960000"
}],
"headers": [ {
"source" : "**/*.@(eot|otf|ttf|ttc|woff|font.css)",
"headers" : [ {
"key" : "Access-Control-Allow-Origin",
"value" : "*"
} ]
}],
"cleanUrls": true,
"trailingSlash": false
}
}
现在在浏览器中检查资产,我看不出对发送的过期 headers 有任何影响。
请问有什么事吗?
您的配置格式不正确 -- 您的 hosting
配置中有多个顶级 headers
。它应该看起来更像:
{
"hosting": {
"public": "public",
"ignore": ["firebase.json", "**/.*", "**/node_modules/**"],
"headers": [
{
"source": "**",
"headers": [
{
"key": "Cache-Control",
"value": "max-age=960000"
}
]
},
{
"source": "404.html",
"headers": [
{
"key": "Cache-Control",
"value": "max-age=960000"
}
]
},
{
"source": "**/*.@(eot|otf|ttf|ttc|woff|font.css)",
"headers": [
{
"key": "Access-Control-Allow-Origin",
"value": "*"
}
]
}
],
"rewrites": [
{
"source": "**",
"destination": "/index.html"
}
],
"cleanUrls": true,
"trailingSlash": false
}
}