Skip to main content

Module key_norm

Module key_norm 

Source
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:

  1. Lowercase — scheme, host, and path are lowercased.
  2. Trailing slash removal — a trailing / on the path component is stripped (unless the path is / itself).
  3. 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.