Opened 10 years ago

Last modified 10 years ago

#24035 closed Bug

Poor/incorrect documentation for CACHE_MIDDLEWARE_KEY_PREFIX in relation to CACHES[alias]['KEY_PREFIX'] — at Initial Version

Reported by: Frankie Robertson Owned by: Frankie Robertson
Component: Documentation Version: dev
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

The interaction between CACHES[alias]KEY_PREFIX, CACHE_MIDDLEWARE_KEY_PREFIX and @cache_page(... key_prefix) is poorly documented. It should be made explicit that KEY_PREFIX is always used and combined with CACHE_MIDDLEWARE_KEY_PREFIX or @cache_page(... key_prefix)

Changes should be made to both ref/settings and topics/cache.

The paragraph at the bottom of https://docs.djangoproject.com/en/dev/topics/cache/#the-per-view-cache is particularly troublesome:

"The two settings can also be combined. If you specify a cache and a key_prefix, you will get all the settings of the requested cache alias, but with the key_prefix overridden.

Having looked through the source it appears as though the setting CACHE_MIDDLEWARE_KEY_PREFIX OR the argument to @cache_page is combined with the rest of the cache key using django.utils.cache.get_cache_key which is then combined with the CACHES[alias]KEY_PREFIX using key_func.

Change History (0)

Note: See TracTickets for help on using tickets.
Back to Top