-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
fix(proxy-cache): follow request Cache-Control: no-cache
header field
#14139
base: master
Are you sure you want to change the base?
Conversation
cache-control
header no-cache
field base on rfc7234
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This fix would change the cached object format instead of only refreshing it. We keep the request body in the cache and the new code is returning before storing it.
My suggestion is to skip the fetch()
call when Cache-Control: no-cache
and setting the correct cache status in the signal_cache_req()
call.
set_header(conf, "X-Cache-Key", cache_key) | ||
if conf.cache_control then | ||
if cc["no-cache"] then | ||
return signal_cache_req(ctx, conf, cache_key, "Bypass") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we return here, we're not caching the request body.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@locao ,
Just out of curiosity, why are we caching the request body? Used somewhere else?
cache-control
header no-cache
field base on rfc7234Cache-Control: no-cache
header
Cache-Control: no-cache
headerCache-Control: no-cache
header field
Summary
Previously, when the header field
Cache-Control
contained the directiveno-cache
, the proxy-cache plugin was not caching at all, which is not the behavior described by RFC-7234.Checklist
changelog/unreleased/kong
orskip-changelog
label added on PR if changelog is unnecessary. README.mdIssue reference
Fix #14120
KAG-6165