Expand description
Cache key normalisation.
normalize_cache_key converts a URL into a canonical form suitable for
use as a cache key. The following transformations are applied:
- Lowercase — scheme, host, and path are lowercased.
- Trailing slash removal — a trailing
/on the path component is stripped (unless the path is/itself). - Query parameter sorting — query string parameters are split on
&, sorted lexicographically, and rejoined. Empty query strings are omitted.
Fragment identifiers (#...) are discarded as they are client-side only.
§Example
use oximedia_cache::key_norm::normalize_cache_key;
let key = normalize_cache_key("https://CDN.Example.com/Video/Clip.mp4/?b=2&a=1#frag");
assert_eq!(key, "https://cdn.example.com/video/clip.mp4?a=1&b=2");Functions§
- normalize_
cache_ key - Normalise a URL into a canonical cache key.