【问题标题】:Firebase Hosting - Clear CacheFirebase 托管 - 清除缓存
【发布时间】:2018-05-07 11:38:59
【问题描述】:

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

ionic build --browser

firebase deploy

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

例如,我创建了一个 ionic and angular 演示项目。使用 InAppBrowser 可以连接 Firebase url

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

Above Image 没有更新值

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

上面的图片,带有更新的文字。上传到 Firebase 后的预期结果。

下面 sn -p 试图限制缓存。

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 或 Default Browser 还是需要在 ionic 3 应用程序中进行任何配置?

【问题讨论】:

  • 您的浏览器正在加载浏览器中的缓存版本。将 html 文件的缓存控制减少到几分钟,并将静态文件的缓存控制设置得非常高。

标签: angular firebase caching ionic3 firebase-hosting


【解决方案1】:

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

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

然后添加css、图像和404。

【讨论】:

  • 这不会清除缓存,它说永远不要存储它,然后在部署时遵守设置。我的理解是 deploy 会自己清除缓存。
猜你喜欢
  • 2019-03-18
  • 2020-08-07
  • 2016-12-05
  • 2020-03-13
  • 2014-08-16
  • 2020-09-12
  • 2020-03-02
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多