firebase.json中的Cache-Control标头不起作用 [英] Cache-Control header in firebase.json not working

查看:78
本文介绍了firebase.json中的Cache-Control标头不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的 firebase.json 中的 Cache-Control 标头似乎不起作用。所有文件的最大年龄值设置为 31536000 (1年),但是在加载页面时仍设置为浏览器默认值 3600 (1小时)。

The Cache-Control header in my firebase.json does not seem to be working. The max-age value for all files is set to 31536000 (1 year), but when loading the page it is still set to the browser default of 3600 (1 hour).

firebase。 json 文件似乎遵守 firebase文档。

{
    "hosting": {
        "public": "public"
    },
    "ignore": [
        "firebase.json",
        "**/.*",
        "**/node_modules/**"
    ],
    "headers": [{
        "source": "**",
        "headers": [{
            "key": "Cache-Control",
            "value": "max-age=31536000"
        }]
    }]
}


推荐答案

根据完整页配置,您必须先设置托管密钥

According to full page configuration you have to set hosting key first.

这必须起作用:

{
  "hosting": {
    "public": "app",
    "ignore": [
      "firebase.json",
      "**/.*",
      "**/node_modules/**"
    ],
    "headers": [{
      "source" : "**",
      "headers" : [{
        "key" : "Cache-Control",
        "value" : "max-age=31536000"
      }]
    }]
  }
}

这篇关于firebase.json中的Cache-Control标头不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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