Setting The Vary Head From Firebase Function
I'm unable to successfully set the Vary header in a firebase function.
My code:
res.set('Vary', 'Accept-Encoding');
Server response:
vary: x-fh-requested-host, accept-encoding, cookie, authorization
I have several functions that return data that I want cached based purely on the 'Accept-Encoding' header. But no matter what I do, firebase appears to overwrite my header with its own. Crucially, it's adding cookie, authorization which break my cache.
My functions are accessed by a url that is rewritten using firebase hosting. According to these docs it should be possible.
Answer
Firebase Hosting automatically adds these headers to Vary
to prevent accidental cross-user cache leaks. This can still work perfectly well with caching, as Firebase Hosting also strips all cookies from the Cookie
header except one named __session
.
If you have content that does not vary based on the Authorization
header, I'd recommend not including that header in your request to the function (since your function should not be using it anyway unless it's part of the Vary
).
Related Questions
- → How can I query Firebase for an equalTo boolean parameter?
- → How can I access nested data in Firebase with React?
- → Firebase simple blog (confused with security rules)
- → Removing item in Firebase with React, re-render returns item undefined
- → AngularJS Unknown Provider Error (Firebase & AngularFire)
- → How do you pass top level component state down to Routes using react-router?
- → "this" is null in firebase query function in reactjs
- → Angular Module Failed to Load
- → Multiple dex files define Lcom/google/android/gms/internal/zzrx;
- → Joining Firebase tables in React
- → How can I make add firepad to my reactjs project?
- → How to use Cloud Functions for Firebase to prerender pages for SEO?
- → React.js component has null state?