Cache-Control header in firebase.json file not working

南笙酒味 提交于 2019-12-10 12:39:28

问题


The Cache-Control header setting in my firebase.json file does not seem to be working. I have set the max-age value, for all files, to 31536000 (1 year). My firebase.json file is-

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

The file seems to abide by the firebase documentation.

But the max-age value, for all files, is still set to the browser default of 3600 (1 hour).


回答1:


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

This have to work:

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


来源:https://stackoverflow.com/questions/38114755/cache-control-header-in-firebase-json-file-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!