#33604: Allow CacheMiddleware.key_prefix to be a callable. -------------------------------------+------------------------------------- Reporter: Alexandru | Owner: Stefan Mărășteanu | Farmbauer Type: New feature | Status: assigned Component: Core (Cache system) | Version: dev Severity: Normal | Resolution: Keywords: | Triage Stage: Accepted Has patch: 1 | Needs documentation: 1 Needs tests: 1 | Patch needs improvement: 1 Easy pickings: 0 | UI/UX: 0 -------------------------------------+------------------------------------- Changes (by Stefan Farmbauer):
* owner: Alexandru Mărășteanu => Stefan Farmbauer Old 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. New 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. (PR is 18254)[https://github.com/django/django/pull/18254] -- -- Ticket URL: <https://code.djangoproject.com/ticket/33604#comment:13> Django <https://code.djangoproject.com/> The Web framework for perfectionists with deadlines. -- You received this message because you are subscribed to the Google Groups "Django updates" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-updates+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/0107018ff86738ba-c004e828-303b-490f-a14d-91f7989d0031-000000%40eu-central-1.amazonses.com.