Skip to content

Latest commit

 

History

History
31 lines (28 loc) · 824 Bytes

add-cache-control-header.md

File metadata and controls

31 lines (28 loc) · 824 Bytes

Add Cache-Control headers

To add headers to your static resources in Firebase hosting, add the headers section within hosting in the firebase.json file:

"hosting": {
  // Add the "headers" section within "hosting".
  "headers": [ {
    "source" : "**/*.@(eot|otf|ttf|ttc|woff|font.css)",
    "headers" : [ {
      "key" : "Access-Control-Allow-Origin",
      "value" : "*"
    } ]
  }, {
    "source" : "**/*.@(jpg|jpeg|gif|png)",
    "headers" : [ {
      "key" : "Cache-Control",
      "value" : "max-age=300000"
    } ]
  }, {
    // Sets the cache header for 404 pages to cache for 5 minutes
    "source" : "404.html",
    "headers" : [ {
      "key" : "Cache-Control",
      "value" : "max-age=300"
    } ]
  } ]
}

More info