Does Firebase hosting provide 304 vs 200 responses?

1,032 views
Skip to first unread message

Marty Nelson

unread,
Jun 29, 2015, 8:05:32 PM6/29/15
to fireba...@googlegroups.com
In our test environment users have to hard refresh to get new resources. We'll be going to production soon and I'm wondering if there's a way to have firebase manage appropriate caching responses or if paid plan behaves differently?

If not, any ideas how to manage?

Chris Raynor

unread,
Jun 29, 2015, 8:42:06 PM6/29/15
to fireba...@googlegroups.com
There are two separate issues here - even with responding with a 304 code when data hasn't been modified, the browser will still respect 'Cache-Control' headers and not even send requests until the cache timeout has expired. By default, sites on Firebase Hosting send a Cache-Control header of 'max-age=3600', which means a browser won't try to request updated resources for 1 hour after it received the first response (unless you hard refresh the page). You can modify the headers in your firebase.json file (see https://www.firebase.com/docs/hosting/guide/url-redirects-rewrites.html#section-headers for more details) but you're trading off for bandwidth to your site and network traffic you're forcing on your users. If you expect a lot of changes to the static content of your site (non-database traffic), or not a lot of repeat visits, then a low max-age might be applicable, but otherwise a maximum delay of 1 hour from a `firebase deploy` to all your users seeing the new site is usually acceptable, if a little short.

We have a task to add Etag headers to responses that would allow our CDN to serve 304 responses when the content hasn't been modified, but that only reduces traffic for repeat visits outside the Cache-Control time. I'm afraid I don't have a timeline on when we might implement that.

Hope that helps

Chris

On Mon, Jun 29, 2015 at 5:05 PM, Marty Nelson <mnels...@gmail.com> wrote:
In our test environment users have to hard refresh to get new resources. We'll be going to production soon and I'm wondering if there's a way to have firebase manage appropriate caching responses or if paid plan behaves differently?

If not, any ideas how to manage?

--
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/ae8fb371-61bc-457e-ac80-ed0aa33f9ff4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Marty Nelson

unread,
Jun 30, 2015, 9:12:49 PM6/30/15
to fireba...@googlegroups.com
Very helpful, thanks Chris. Looking forward to Etags!

Bruno Alexandre

unread,
Aug 11, 2015, 9:51:10 PM8/11/15
to Firebase Google Group
There is no cdn serve 304, waiting!
Reply all
Reply to author
Forward
0 new messages