get_cache_key
Return a cache key based on the request URL and query. It can be used in the request phase because it pulls the list of headers to take into account from the global URL registry and uses those to build a cache key to check against. If there isn't a headerlist stored, return None, indicating that the page needs to be rebuilt.
def get_cache_key(
request: HttpRequest,
key_prefix: string = None,
method: string = "GET",
cache: BaseCache = None
) - > string
Return a cache key based on the request URL and query. It can be used in the request phase because it pulls the list of headers to take into account from the global URL registry and uses those to build a cache key to check against.
Parameters
| Name | Type | Description |
|---|---|---|
| request | HttpRequest | The Django request object used to derive the URL and query parameters for the key. |
| key_prefix | string = None | A prefix string to prepend to the cache key, defaulting to the CACHE_MIDDLEWARE_KEY_PREFIX setting. |
| method | string = "GET" | The HTTP method to associate with the cache key. |
| cache | BaseCache = None | The specific cache backend instance to query for header lists; defaults to the CACHE_MIDDLEWARE_ALIAS setting. |
Returns
| Type | Description |
|---|---|
string | The generated cache key string if a header list exists, or None if the page needs to be rebuilt. |