firebase - 托管在 Firebase 上的 Ionic 应用程序需要清除缓存
问题描述
我在 firebase 上托管了一个 ionic 4 应用程序,当我推送更新时,我的用户必须清除他们的缓存才能加载该应用程序的最新版本。
我搜索了一下并修改了我firebase.json
的以反映以下内容:
{
"hosting": {
"public": "www",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
],
"headers": [
{ "source":"/service-worker.js", "headers": [{"key": "Cache-Control", "value": "no-cache"}] }
],
"rewrites": [
{
"source": "**",
"destination": "/index.html"
}
]
}
}
我认为这行得通,但今天我推送了更新,它要求我清除缓存。有人对如何强制更新有其他想法吗?
解决方案
尝试改变这个
"headers": [{"key": "Cache-Control", "value": "no-cache"}]
对此
"headers": [{"key": "Cache-Control", "value": "no-cache, no-store, must-revalidate"]
或这个
"headers": [{"key": "Cache-Control", "value": "public, max-age=0"}]
另外,您正在为 设置规则"source" : "/service-worker.js"
,这是您想要的吗?
我想你想要这个:
"headers": [
{
"source": "/**",
"headers": [
{
"key": "Cache-Control",
"value": "no-cache, no-store, must-revalidate"
}
]
}]
看看他们在这个答案中做了什么
这可能会降低用户的性能
推荐阅读
- python - KeyError:networkX中的“颜色”
- python - 合并两个数据帧时的内存问题
- javascript - NextJS 如何创建动态后端路由
- javascript - 如何使用 addEventListener (keyup) 而不是 HTML 中的 onkeyup 属性获得相同的结果?
- visual-studio-code - 在 VSCode 扩展中,如何用从另一个文件读取的内容填充未命名的未保存文件?
- ios - React Native,ITMS-90078:缺少推送通知权利
- python - 当没有函数来计算要获取的记录总数时,如何使用 API 使用 Python 提取数据
- php - 未捕获的错误:找不到类“Illumninate\Support\Collection”
- python - /polls/add/ 处的 ValueError 视图 polls.views.addQuestion 未返回 HttpResponse 对象。它返回 None 而不是
- azure - Visual Studio 2019 无法创建 ADO.NET 实体数据模型