feat(cache)!: tag HTTP cache keys http:v2 and separate them with one | - #406
Merged
Merged
Conversation
Every client-controlled component is percent-encoded, so a single `|` is
enough to separate them. Keys now start with the format tag `http:v2`
(`CacheKey.FORMAT_TAG`), so a later format never collides with this one
and `clear_pattern("http:v2|*")` removes every key of it.
`CacheKey.parse()` only reads tagged keys, so `clear_path()` and the
monitoring routes skip 0.3.x keys and keys from a key builder that does
not use `build_cache_key()`. The path-shaped `clear_pattern` warning now
suggests a pattern that also matches a path with no glob.
BREAKING CHANGE: HTTP cache keys change from `method|||host|||path|||query`
to `http:v2|method|host|path|query`, and `CACHE_KEY_SEPARATOR` is `"|"`.
Entries written by 0.3.x are not read.
Closes #271
Closes #266
This was referenced Sep 29, 2026
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.
Second of the 0.4.0 cache-key changes, on top of
CacheKey(#405).What changes
CACHE_KEY_SEPARATORis"|". Method, host, path and extra components are percent-encoded and the query is URL-encoded, so none of them can contain it (0.4.0: use a single | as the cache-key separator #271).http:v2(CacheKey.FORMAT_TAG):http:v2|method|host|path|query|extra.... A later format gets another tag, andclear_pattern("http:v2|*")removes every key of this one (Cache key: add a format version tag to HTTP keys #266).CacheKey.parse()returnsNonefor untagged keys.clear_path()and the monitoring routes therefore skip 0.3.x keys and keys from akey_builderthat builds its own string instead of callingbuild_cache_key(). Such builders still cache,invalidate()andclear_pattern(); the docs say so.CacheKey.path_glob()includes the tag.clear_patternwarning now suggestshttp:v2|GET|*|<pattern>|*, which also matches a path with no glob.Docs
CACHE_FLOW.md,HTTP_CACHING.mdandMIGRATING_0_4.md, in English and zh-TW:clear_patternexample is now"http:v2|GET|*";*|||*cleanup pattern matches any key containing|||.changelog.d/125.removed.mdnow gives the 0.4.0 pattern.Tests
parse()rejecting 0.3.x, other-tag, untagged, query-less and method-less keys.path_globmatches only tagged keys.clear_pattern("*|||*")removes 0.3.x keys and leaves current ones.Closes #271
Closes #266