Opened 3 years ago

Last modified 5 months ago

#33604 assigned New feature

Allow `CacheMiddleware.key_prefix` to be a callable — at Initial Version

Reported by: Alexandru Mărășteanu Owned by: nobody
Component: Core (Cache system) Version: dev
Severity: Normal Keywords:
Cc: Tobias Kunze Triage Stage: Accepted
Has patch: yes Needs documentation: yes
Needs tests: yes Patch needs improvement: yes
Easy pickings: no UI/UX: no

Description

As discussed in https://groups.google.com/g/django-developers/c/UbD1DkV1uPo and https://code.djangoproject.com/ticket/11269 it would be useful to be able to specify a callable which would allow for more dynamic caching. In my case, I need to cache differently depending on whether the user is authenticated or not. Another scenario is to cache certain pages depending on some timestamp. Other uses cases were mentioned in the linked pages.

There exists https://github.com/peterbe/django-fancy-cache but I was able to address this by extending the built-in middleware so I really don't see an argument for a 3rd party package.

I'll try to open a PR for this.

Change History (0)

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