Skip to content

Fix handling of cached responses with variants and different ETag values.#421

Merged
ok2c merged 1 commit intoapache:5.3.xfrom
arturobernalg:feature/vary-header-cache
Mar 12, 2023
Merged

Fix handling of cached responses with variants and different ETag values.#421
ok2c merged 1 commit intoapache:5.3.xfrom
arturobernalg:feature/vary-header-cache

Conversation

@arturobernalg
Copy link
Copy Markdown
Member

Fix handling of cache entries with variants that have different ETag values

Previously, the getCacheEntry method 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.

…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 ok2c merged commit 20bdd46 into apache:5.3.x Mar 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants