-
Notifications
You must be signed in to change notification settings - Fork 275
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 directive conflicts in cache control header #6543
Conversation
Signed-off-by: Benjamin <[email protected]>
✅ Docs preview readyThe preview is ready to be viewed. View the preview File Changes 0 new, 1 changed, 0 removed
Build ID: bcd42b0fd1c0883e3a8b9768 URL: https://www.apollographql.com/docs/deploy-preview/bcd42b0fd1c0883e3a8b9768 |
This comment has been minimized.
This comment has been minimized.
CI performance tests
|
Signed-off-by: Benjamin <[email protected]>
Co-authored-by: Ivan Goncharov <[email protected]>
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.
I think we should consider moving https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control#preventing_storing
logic here:
fn merge_inner(&self, other: &CacheControl, now: u64) -> CacheControl { |
Because:
In theory, if directives are conflicted, the most restrictive directive should be honored.
So we should handle other conflicting directives like: max-age=0, max-age=60
And already have this code here:
router/apollo-router/src/plugins/cache/cache_control.rs
Lines 275 to 278 in f923298
(Some(ttl1), Some(ttl2)) => Some(std::cmp::min( | |
self.update_ttl(ttl1, now), | |
other.update_ttl(ttl2, now), | |
)), |
So I think the same function should also have logic that no-cache
and no-store
wipe out other directives.
I think it would be better solution since we have some logic around CacheControl
and also store it in context that means we apply no-cache
and no-store
more consistently across the plugin.
Because in current version we apply no-cache
and no-store
only before we send response back to a client.
Signed-off-by: Benjamin <[email protected]>
Signed-off-by: Benjamin <[email protected]>
@bnjjj I think we should have changeset entry for it. |
Signed-off-by: Benjamin <[email protected]>
@Mergifyio backport 1.x |
✅ Backports have been created
|
Signed-off-by: Benjamin <[email protected]> Co-authored-by: Ivan Goncharov <[email protected]> (cherry picked from commit 620acac)
Unnnecessary cache-control directives are created in cache-control header. The router will now filter out unnecessary values from the
cache-control
header when the request resolves. So if there'smax-age=10, no-cache, must-revalidate, no-store
, the expected value for the cache-control header would simply beno-store
. Please see the MDN docs for justification of this reasoning: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control#preventing_storingFixes #6441
Checklist
Complete the checklist (and note appropriate exceptions) before the PR is marked ready-for-review.
Exceptions
Note any exceptions here
Notes
Footnotes
It may be appropriate to bring upcoming changes to the attention of other (impacted) groups. Please endeavour to do this before seeking PR approval. The mechanism for doing this will vary considerably, so use your judgement as to how and when to do this. ↩
Configuration is an important part of many changes. Where applicable please try to document configuration examples. ↩
Tick whichever testing boxes are applicable. If you are adding Manual Tests, please document the manual testing (extensively) in the Exceptions. ↩