Skip to main content

get_cache_key

Function get_cache_key 

Source
pub fn get_cache_key(
    ctx: &Ctx,
    method: &str,
    header: &RequestHeader,
) -> CacheKey
Expand description

Generates the cache key of a request.

The primary is, in this order: the namespace, the custom keys (each followed by :), the method, :, the host in lower case without its port, then the path and the query. user_tag is the namespace.

The host is part of the key whatever the protocol. It used to come from the request uri alone, which carries it in HTTP/2 but not in HTTP/1.1: two domains behind one cache plugin answered with each other’s pages over HTTP/1.1, and a PURGE sent over one protocol missed what the other had stored. Scheme and port are left out on purpose, so a PURGE sent to an internal plain-http listener with the right Host clears what the public https listener cached.

§Arguments

  • ctx - The Ctx context containing cache configuration.
  • method - The HTTP method as a string.
  • header - The request the key is for: its host, path and query.