gpt4 book ai didi

firebase-hosting - 如何在 Firebase 托管 header 规则中定位域根

转载 作者:行者123 更新时间:2023-12-04 13:46:29 39 4
gpt4 key购买 nike

我有一个使用自定义域的网络应用程序。此域具有映射到 151.101.1.195 和 151.101.65.195 的 A 记录。

一切正常,但是当我有 firebase.json 时:

{
"hosting": {
"public": "dist",
"headers": [{
"source": "**/*.html",
"headers": [{
"key": "Cache-Control",
"value": "private, max-age=0, no-cache"
}]
}]
}
}

当我访问 https://mycustomdomain.com 时,我仍然看到这样的响应 header :
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

我希望缓存控制头被修改,但它不会改变。

如何更改域根的响应 header ?

最佳答案

对于任何人来说,我最终都是这样做的,它似乎有效:

{
"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" }
]
}
}

这也适用于函数。请注意,.js 文件也被积极缓存,因为我们使用缓存破坏 url。

关于firebase-hosting - 如何在 Firebase 托管 header 规则中定位域根,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46441557/

39 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com