Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#24035 closed Bug (fixed)

Poor/incorrect documentation for CACHE_MIDDLEWARE_KEY_PREFIX in relation to CACHES[alias]['KEY_PREFIX']

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 (last modified by Tim Graham)

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 (4)

comment:1 by Tim Graham, 10 years ago

Description: modified (diff)
Triage Stage: UnreviewedAccepted

comment:2 by Tim Graham <timograham@…>, 10 years ago

Resolution: fixed
Status: newclosed

In 446b50b90e9e60760618b236d8b0ea75a3b19d5a:

Fixed #24035 -- Clarified docs on CACHE_MIDDLEWARE_KEY_PREFIX vs KEY_PREFIX

comment:3 by Tim Graham <timograham@…>, 10 years ago

In 70c965ad4ff06337229c4095a2b2221467781b92:

[1.6.x] Fixed #24035 -- Clarified docs on CACHE_MIDDLEWARE_KEY_PREFIX vs KEY_PREFIX

Backport of 446b50b90e9e60760618b236d8b0ea75a3b19d5a from master

comment:4 by Tim Graham <timograham@…>, 10 years ago

In 126eb58abef119b799f81bd3626cb777910847cf:

[1.7.x] Fixed #24035 -- Clarified docs on CACHE_MIDDLEWARE_KEY_PREFIX vs KEY_PREFIX

Backport of 446b50b90e9e60760618b236d8b0ea75a3b19d5a from master

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