Apply stale-while-revalidate also for responses without a validator#208
Open
pilif wants to merge 1 commit intoKevinrob:masterfrom
Open
Apply stale-while-revalidate also for responses without a validator#208pilif wants to merge 1 commit intoKevinrob:masterfrom
pilif wants to merge 1 commit intoKevinrob:masterfrom
Conversation
a7d25e6 to
9d515ed
Compare
Author
|
the test is failing due to an interaction between https://datatracker.ietf.org/doc/html/rfc5861 an The code is currently re-requesting the resource because it doesn't see the I will make the required adjustments. |
Due to its name, the stale-while-revalidate Cache-Control extension might suggest that it only applies to revalidation requests. However, looking at https://tools.ietf.org/html/rfc5861#section-3... > The stale-while-revalidate Cache-Control Extension > When present in an HTTP response, the stale-while-revalidate > Cache-Control extension indicates that caches MAY serve the > response in which it appears after it becomes stale, up to the > indicated number of seconds. > stale-while-revalidate = "stale-while-revalidate" "=" delta-seconds > If a cached response is served stale due to the presence of this > extension, the cache SHOULD attempt to revalidate it while still > serving stale responses (i.e., without blocking). There is no reason why a cache should not also return a stale response while a complete re-fetch happens in the background (just what would happen if validation fails). This makes a difference if, for example, a resource has `Cache-Control: public, max-age=30, stale-while-revalidate=30` set and no additional Last-Modified or ETag headers. Co-Authored-By: Philip Hofstetter <phofstetter@sensational.ch
9d515ed to
c5d2625
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
this is an updated version of #128, rebased on top of current
HEADand with a fix to the test to reflect the new reality (which is what #128 was waiting on for 2 years).This is super useful when talking to a server outside of the caller's control if a stale response is always preferable to no response and if the server is living in the past and providing no useful cache validation feature.
In this case, a stale response can still be served from cache while a full download happens in the background