【发布时间】:2020-08-07 18:34:27
【问题描述】:
我们构建了一个 Flutter Web 应用并通过 Firebase 托管进行部署。不幸的是,我们在初始部署中没有配置任何缓存设置。
现在我们部署了更新版本的网站,但人们仍然会从第一次部署中看到旧网站。到目前为止我们尝试了什么:
添加版本号到我们的 index.html:
<"script src="main.dart.js?version=1" type="application/javascript"></script>
在 index.html 的标头中添加元数据:
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Expires" content="0" />
在我们的 firebase.json 中,我们添加了以下标头:
"headers": [
{
"source": "**",
"headers": [
{
"key": "Cache-Control",
"value": "max-age=10"
}
]
}
]
所有这些尝试都没有成功。我们认为问题在于较新版本的文件中没有这些条目。我们如何强制它更新到我们的最新版本?如果有帮助,我们甚至会考虑开设一个新的 firebase 项目。
非常感谢您的帮助!
【问题讨论】:
-
你能成功做到这一点吗?
标签: firebase flutter web caching hosting