Cache Keys#
Internal utilities for generating the cache keys that are used to match requests
Create a normalized cache key from either a request object or |
|
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
request (
Union
[Request
,PreparedRequest
,CachedRequest
,None
]) – Request object to generate a cache key fromignored_parameters (
Optional
[Iterable
[str
]]) – Request parames, headers, and/or body params to not match againstmatch_headers (
Union
[Iterable
[str
],None
,bool
]) – Match only the specified headers, orTrue
to match all headersrequest_kwargs – Request arguments to generate a cache key from
- Return type
- requests_cache.cache_keys.normalize_request(request, ignored_parameters=None)[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
request (
Union
[Request
,PreparedRequest
,CachedRequest
]) – Request object to normalizeignored_parameters (
Optional
[Iterable
[str
]]) – Request parames, headers, and/or body params to not match against and to remove from the request
- Return type