Cache-Control header in firebase.json file not wor

2019-06-16 04:00发布

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).

Cache-Control is stil an hour

1条回答
何必那么认真
2楼-- · 2019-06-16 04:24

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"
      }]
    }]
  }
}
查看更多
登录 后发表回答