Fix handling of cached responses with variants and different ETag values.#421
Merged
ok2c merged 1 commit intoapache:5.3.xfrom Mar 12, 2023
Merged
Conversation
…ues. Previously, the getCacheEntry method was not correctly selecting the matching variant for a given request, which led to incorrect behavior when serving cached responses. This commit improves the method's logic to correctly identify the cache entry using the request's cache key, and then select the variant with the matching ETag value. If no matching variant is found, the cache entry is considered stale and a new response is fetched from the origin server. The fix includes a new test case to ensure the correct behavior of the method in this scenario
ok2c
approved these changes
Mar 11, 2023
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.
Fix handling of cache entries with variants that have different ETag values
Previously, the
getCacheEntrymethod was not correctly handling cache entries with variants that had different ETag values. This was leading to incorrect behavior when serving cached responses, which resulted in failing tests.This commit fixes the issue by correctly identifying the cache entry using the request's cache key, and then selecting the variant with the matching ETag value. If there is no matching variant, the cache entry is considered stale and a new response is fetched from the origin server.
This change is aligned with RFC7232 section 2.3 which states that when an origin server sends multiple representations of a resource with different ETag values, a cache should cache all of them. This means that the cache should be able to correctly identify and serve any of the cached variants based on their ETag values.