-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Minor cleanups in HttpCache, especially centralize Date header fixup #22033
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
Conversation
This makes use of the fact that all requests to the backend go through this method. Backends should provide a Date header indicating the time at which the response was generated. But if (for whatever reason) they don't, we'll keep the time at which the response was received as the response Date. To-Do: Review the RFC; it probably suggests using the time at which the request was initiated, not the time the response was received.
Thanks for your contribution. 😄 Is it possible to add a test case that exposes this issue? |
I will add that once I have found/understood it. For now, this PR is intended as a refactoring that helps (at least me) to better follow execution paths through the |
#19390 added a check in the |
merging into master as this is not really a bug fix |
Thank you @mpdude. |
…header fixup (mpdude) This PR was submitted for the 2.8 branch but it was merged into the 3.3-dev branch instead (closes #22033). Discussion ---------- Minor cleanups in HttpCache, especially centralize Date header fixup | Q | A | ------------- | --- | Branch? | 2.8 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | | License | MIT | Doc PR | I am trying to hunt some issues where the HTTP cache does not revalidate responses (or does not use a cached response?) in the edge case of having `s-maxage = 0` and possibly a backend that's slow to respond. I don't see yet what exactly my problem is there, but it must somehow be related with the `Date` header handling and/or age calculations in the `HTTPCache`. As a first step, I'd like to suggest this cleanup in `HTTPCache`. Especially, it would be helpful if we could make sure that there is just one place where we set the `Date` header if the backend does not send one (?). This makes sure we always have this header to base later age calculations on it. Commits ------- 30639c6 Minor cleanups in HttpCache, especially centralize Date header fixup
… (first?) test for it (mpdude) This PR was squashed before being merged into the 3.3-dev branch (closes #22043). Discussion ---------- Refactor stale-while-revalidate code in HttpCache, add a (first?) test for it | Q | A | ------------- | --- | Branch? | 2.8 | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | | License | MIT | Doc PR | I came up with this while trying to hunt a production bug related to handling of stale cache entries under the condition of a busy backend (also see #22033). It's just a refactoring to make the code more readable plus a new test. Commits ------- b14057c Refactor stale-while-revalidate code in HttpCache, add a (first?) test for it
I am trying to hunt some issues where the HTTP cache does not revalidate responses (or does not use a cached response?) in the edge case of having
s-maxage = 0
and possibly a backend that's slow to respond.I don't see yet what exactly my problem is there, but it must somehow be related with the
Date
header handling and/or age calculations in theHTTPCache
.As a first step, I'd like to suggest this cleanup in
HTTPCache
. Especially, it would be helpful if we could make sure that there is just one place where we set theDate
header if the backend does not send one (?). This makes sure we always have this header to base later age calculations on it.