Cache Keys

Internal utilities for generating the cache keys that are used to match requests

create_key

Create a normalized cache key from either a request object or Request arguments

normalize_request

Normalize and remove ignored parameters from request URL, body, and headers.

requests_cache.cache_keys.create_key(request=None, ignored_parameters=None, match_headers=False, **request_kwargs)[source]

Create a normalized cache key from either a request object or Request arguments

Parameters
Return type

str

requests_cache.cache_keys.normalize_request(request, ignored_parameters)[source]

Normalize and remove ignored parameters from request URL, body, and headers. This is used for both:

  • Increasing cache hits by generating more precise cache keys

  • Redacting potentially sensitive info from cached requests

Parameters
Return type

Union[PreparedRequest, CachedRequest]