当您重新删除云运行中的Web应用程序时,是否有必要更新Firebase,您是否可以控制重新部署期间从缓存中删除的内容?

发布于 2025-01-21 00:09:31 字数 1008 浏览 0 评论 0原文

使用 firebase + 云运行部署 Web 应用程序后,firebase 配置通常不会发生太大变化。

问题1

是否建议更新云运行容器而不执行 在 firebase 上重新部署?

使用云运行更新 Firebase 的建议方法是什么?假设不想丢失 Firebase 上已有的缓存。根据 firebase 的说法,重新部署 Web 应用程序会清除所有 CDN 缓存。

问题 2

这是我的情况

我有一个 Web 应用程序托管在 cloud run + firebase 上,每当我进行重新部署时,我想要从 CDN 的 API 缓存的任何内容 >不被清除。剩下的就可以清除了。

有没有办法控制在期间从缓存中清除的内容 重新部署?

这是我的配置

{
  "hosting": {
    "public": "public",
    "ignore": [
      "firebase.json",
      "**/.*",
      "**/node_modules/**"
    ],
    "rewrites": [ {
      "source": "**",
      "run": {
        "serviceId": "my-site",
        "region": "some-region" 
      }
    } ],
    "headers": [{
      "source" : "**",
      "headers" : [
      {
        "key" : "Cache-Control",
        "value" : "max-age=31536000"
      }
    ]
    }]
  }
}

After deploying a web app with firebase + cloud run the firebase configurations usually don't change much.

Question 1

Is it advisable to update the cloud run container without doing a
re-deployment on firebase ?

What's the advisable way to update firebase with cloud run let's say don't want to lose cache already on firebase. According to firebase a re-deployment of the web app clears all CDN cache.

Question 2

Here is my situation

I have a web app hosted on cloud run + firebase whenever I do a re-deployment I want whatever is cached from my API's from CDN not to be cleared. The rest can be cleared.

Is there a way to control what's cleared from cache during
re-deployments ?

Here is my configurations

{
  "hosting": {
    "public": "public",
    "ignore": [
      "firebase.json",
      "**/.*",
      "**/node_modules/**"
    ],
    "rewrites": [ {
      "source": "**",
      "run": {
        "serviceId": "my-site",
        "region": "some-region" 
      }
    } ],
    "headers": [{
      "source" : "**",
      "headers" : [
      {
        "key" : "Cache-Control",
        "value" : "max-age=31536000"
      }
    ]
    }]
  }
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

昔梦 2025-01-28 00:09:31

建议在不进行firebase重新部署的情况下更新云运行容器吗?

每当您更新云运行容器时,更改将不会更新到firebase,如果您希望将更改更新为firebase托管,则应考虑部署到firebase firebase deplotion-仅托管

是否有一种方法可以控制从缓存中清除的内容
重新部署?

根据 doc

任何请求的静态内容都会自动缓存在CDN上。如果
您重新部署了网站的内容,firebase会自动托管
清除整个CDN的所有缓存静态内容,直到下一个
请求。

例如,如果您有动态内容,则可以通过admin UI编辑。请注意,CDN缓存将保留该内容的陈旧缓存,直到其到期为止。
例如:CDN CACHES /BLOB /SONE SONE-STOST,S-MAXAGE为1天。即使您动态地更改帖子的内容,CDN也将使CDN整天保持一整天,直到它到期并再次请求。

Is it advisable to update the cloud run container without doing a re-deployment on firebase ?

Whenever you update the Cloud Run container, the changes will not be updated to the Firebase, if you want the changes to be updated to the Firebase hosting then you should consider deploying to the Firebase firebase deploy --only hosting.

Is there a way to control what's cleared from cache during
re-deployments ?

According to the doc

Any requested static content is automatically cached on the CDN. If
you redeploy your site's content, Firebase Hosting automatically
clears all your cached static content across the CDN until the next
request.

If you have dynamic content that you'll edit through an admin UI, for example. Be aware that the CDN cache will keep stale cache of that content until it expires.
For example: CDN caches /blog/some-post with s-maxage of 1 day. Even if you change the content of your post dynamically, the CDN will keep the CDN for 1 full day, until it expires and it gets requested again.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文