forked from tobi/cacheable
-
Notifications
You must be signed in to change notification settings - Fork 18
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
Collapse cache entry to single key #67
Merged
Merged
Conversation
This file contains 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
colinbendell
force-pushed
the
single_cache_key
branch
from
March 27, 2023 16:14
0f85693
to
1ebda60
Compare
colinbendell
force-pushed
the
single_cache_key
branch
from
March 27, 2023 16:18
1ebda60
to
37cdf59
Compare
colinbendell
force-pushed
the
single_cache_key
branch
from
March 27, 2023 19:45
d0a537f
to
1eda0f4
Compare
* uses single cache key * stores the headers in the cache to make the etag available * validates against the etag for strict cache hit * soft etag matches based on TTL for a stale-while-revalidate
colinbendell
force-pushed
the
single_cache_key
branch
from
March 27, 2023 19:46
1eda0f4
to
b317df3
Compare
rafaelfranca
approved these changes
Mar 27, 2023
Co-authored-by: Rafael Mendonça França <[email protected]>
casperisfine
approved these changes
Mar 28, 2023
drinkbeer
reviewed
Apr 3, 2023
drinkbeer
reviewed
Apr 4, 2023
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.
Previously a cache miss would be cached twice - an unversioned entry + a versioned entry for the same cache key. This would allow cases where the versioned entry was not strictly needed and shouldn't cause a cache miss (eg: bot traffic). However, this doubling of the cache entries reduces the effective memory footprint and requires multiple round trips to the backing cache.
This PR collapses the cache to a single key and uses the entity-tag (
etag
) value for the situations when a strict cache value needs to be evaluated. This reduces the number of queries to the cache while preserving the intended semantics of the cache.Additionally, we move the a limited header set into the cache. Header caching is required for response metadata caching and will support other use cases such as the use of
cache-tags
and othercache-control
header values.Other changes in this pr:
cache_key
--> is for the lookup,entity_tag
is for the version)x-alternate-cache-key
Future work should include:
x-cache
header to the standardcache-status
header