Firebase 托管 - 清除缓存

问题描述 投票:0回答:1

按照 Firebase 教程实现 Firebase 托管。在控制台中托管应用程序。但问题是当我更改 html 模板并通过运行在 Firebase 控制台中重新部署时

ionic build --browser

firebase deploy

它正在部署,但没有在移动浏览器中更新。

例如,我创建了一个 ionic 和 angular 演示项目。使用 InAppBrowser 能够连接 Firebase url

this.iab.create('https://xxx-xxxx.firebaseapp.com','_blank',"location=no,clearsessioncache=yes,clearcache=yes");

上图没有更新值

但是当我尝试在应用程序设置中清除应用程序缓存时。然后我得到输出

上面的图像带有更新的文本。上传到 firebase 后的预期结果。

下面的代码片段尝试限制缓存。

1. clearsessioncache=yes,clearcache=yes given in InAppBrowser

2.在Firebase.json中

"headers": [ {
  "source" : "**/*.@(eot|otf|ttf|ttc|woff|font.css)",
  "headers" : [ {
    "key" : "Access-Control-Allow-Origin",
    "value" : "*"
  } ]
}, {
  "source" : "**/*.@(jpg|jpeg|gif|png)",
  "headers" : [ {
    "key" : "Cache-Control",
    "value" : "max-age=7200"
  } ]
}, {
  "source" : "404.html",
  "headers" : [ {
    "key" : "Cache-Control",
    "value" : "max-age=300"
  } ]
} ],
"cleanUrls": true

我不确定,问题出在 InAppBrowser 或默认浏览器上,或者需要在 ionic 3 应用程序中完成任何配置?

angular firebase caching ionic3 firebase-hosting
1个回答
0
投票

尝试使用以下方法清除所有缓存:

  "headers": [
    {
      "source": "**",
      "headers": [
        {
          "key": "Cache-Control",
          "value": "no-cache, no-store, must-revalidate"
        }
      ]
    }
  ]

然后添加 css、图片和 404。

© www.soinside.com 2019 - 2024. All rights reserved.