Firebase Hosting - CDN cache-control questions

1,434 views
Skip to first unread message

Matt

unread,
May 24, 2017, 12:32:19 AM5/24/17
to Firebase Google Group
Am I fine to use a cache-control max age of 1 year as it looks like (and I have read) that on deploy everything is invalidated on the CDN.

Is there any way to see CDN stats of hits/misses, locations etc. I do use Google Analytics.

What is the correct way to set a cache-control header on index.html, the following don't seem to work and I get the usual max-age=3600 response. Posting the full firebase.json incase something conflicts.

Thanks in advance!!

{
  "hosting": {
    "public": "public",
    "rewrites": [
      {
        "source": "**",
        "destination": "/index.html"
      }
    ],
  
"headers": [ {
  "source" : "**/*.@(eot|otf|ttf|ttc|woff|font.css)",
  "headers" : [ {
    "key" : "Access-Control-Allow-Origin",
    "value" : "*"
  } ]
}, {
  "source" : "**/*.@(jpg|jpeg|gif|png|ico|webp|js)",
  "headers" : [ {
    "key" : "Cache-Control",
    "value" : "max-age=604800"
  } ]
}, {
  "source" : "**/*.@(html|css",
  "headers" : [ {
    "key" : "Cache-Control",
    "value" : "max-age=7200"
  } ]
  }, {
  "source" : "index.html",
  "headers" : [ {
    "key" : "Cache-Control",
    "value" : "max-age=604800"
  } ]
} ]

  }
}



Michael Bleigh

unread,
May 24, 2017, 3:07:45 PM5/24/17
to Firebase Google Group
The Cache-Control header on Firebase Hosting static content is telling the browser what to cache, not the CDN. So unless you're using asset fingerprinting to guarantee unique URLs every time you redeploy, you should not set longer Cache-Control max age than you're comfortable having cached in someone's browser.

--
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-tal...@googlegroups.com.
To post to this group, send email to fireba...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/1cc27360-c470-446c-bc71-14c5a5e9c517%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages