#5815: Adds per-view cache refreshing (clearing) -------------------------------------+------------------------------------- Reporter: k0001 | Owner: Ahter | Sönmez Type: New feature | Status: assigned Component: Core (Cache system) | Version: dev Severity: Normal | Resolution: Keywords: cache refresh clear | Triage Stage: Accepted Has patch: 1 | Needs documentation: 0 Needs tests: 1 | Patch needs improvement: 1 Easy pickings: 0 | UI/UX: 0 -------------------------------------+-------------------------------------
Comment (by Carlton Gibson): #34271 was a duplicate with a suggestion to make the cache key just depend on the request path: {{{ from pathlib import Path from django.conf import settings from django.core.cache import caches default_cache = caches[settings.CACHE_MIDDLEWARE_ALIAS] cache_key = ".".join(Path(request.path[1:]).parts) if not (response := default_cache.get(cache_key)): response = view_func(request, *args, **kwargs) response.add_post_render_callback( lambda r: default_cache.set(cache_key, r, timeout) ) }}} That would be easy to invalidate outside the request context. Allowing/documenting easier make_key customisation might allow us to move this forward? 🤔 -- Ticket URL: <https://code.djangoproject.com/ticket/5815#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/01070185c4f60397-4090cb00-f2ea-4e0a-9f2f-8372255aca3b-000000%40eu-central-1.amazonses.com.