Firebase托管Flutter Web App无法清除首次部署的缓存 [英] Firebase Hosting Flutter Web App not clearing Cache of first deploy

查看:224
本文介绍了Firebase托管Flutter Web App无法清除首次部署的缓存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们构建了一个波动的Web应用程序,并通过Firebase托管对其进行了部署。不幸的是,我们没有在初始部署中配置任何缓存设置。

We build a flutter web app and deployed it via firebase hosting. Unfortunately, we didnt configure any caching settings in our initial deploy.

现在,我们部署了较新版本的网站,但是人们仍然可以从第一次部署中看到旧的网站。到目前为止我们尝试过的操作:

Now we deployed a newer version of our website but people still get the old website shown form the first deploy. What we tried so far:

添加版本号。到我们的index.html:

Adding version no. to our index.html:

<"script src="main.dart.js?version=1" type="application/javascript"></script>

在index.html的标头中添加元数据:

Adding meta Data in our header in 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文件中,我们添加了以下标头:

In our firebase.json we added the following headers:

"headers": [
      {
        "source": "**",
        "headers": [
          {
            "key": "Cache-Control",
            "value": "max-age=10"
          }
        ]
      }
    ]

所有这些尝试都没有运气,我们认为问题在于较新的版本没有文件中有这些条目。我们如何强制更新到我们的最新版本?

All of these attemps were without any luck. We think that the problem is that the newer version doesnt have those entries in the files. How can we force this to update to our newest version? We even consider opening a new firebase project if that might help.

非常感谢您的帮助!

推荐答案

尝试以下操作:

在flutter应用中,在Web文件夹内的index.html中,在 src = main.dart.js

In your flutter app, in the index.html within the web folder, add a version number after the src="main.dart.js

所以您的新行将如下所示:

So your new line will look like this:

< script src = main.dart.js?version = 1 type = application / javascript>< / script>

然后在每次构建之前将版本号增加到2,以此类推。

Then increment the version number to 2, etc before you do each build.

这篇关于Firebase托管Flutter Web App无法清除首次部署的缓存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆