-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cloudflare ignores Cache-Control when Surrogate-Control is present #282
Comments
👍 I've been getting around this with something like Where cacheTTL is the calculated TTL based off Cache-Control and some other headers. 100% agreed re making the surrogate control header configurable. I'm not sure about making Cache-Control configurable. I think the behaviour would need to be heavily documented and I'm not clear on what the behaviour should be. Are you saying that if a custom |
Interesting. I suppose I could do something similar, but I think I'd still have to resort to |
Interesting I didn't realise that If I made cache-control configurable would you expect the library to just treat the configured header exactly the same as I'm not sure that would work as peoples browsers would still likely cache things which causes issues. Since So the only thing that matters is down stream (ie peoples browsers). |
Yeah,
That sounds right – if the reason to set
|
Interestingly, it seems this behavior comes from the
…which I suppose is probably why CDNs need |
@timkelty I'll get the Surrogate-Control header changes released later on this week when I merge it in. I'm not convinced there is a need to move the Cache-Control header off to a different header as by the time it hits the worker it's POST CDN Consumption and the only thing down stream is the end users browser. That browser is only going to be interested in If you still think there is a valid use case for it please let me know. |
Thanks so much! Yep – agreed about |
Cloudflare will ignore any
Cache-Control
directives if anySurrogate-Control
header is present: https://developers.cloudflare.com/cache/concepts/cdn-cache-control/#header-precedenceThis becomes a problem if you're relying on origin cache control via the
Cache-Control
header.I've been able to work around this so far by using the CDN-Cache-Control to control Cloudflare caching instead.
That said, the library seems to assume
Cache-Control
is being used in a few places.To make working around this a bit easier, what do you think about:
Surrogate-Control
header configurable, so you could have your origin send something likeX-Surrogate-Control
, to get around Cloudflare's behavior of ignoringCache-Control
Cache-Control
header configurable, so you could override it to useCDN-Cache-Control
orCloudflare-CDN-Cache-Control
if you were using thoseThe text was updated successfully, but these errors were encountered: