This is an (overly simple) example of how to manually delete something from the cache.
Usage is simply
This most likely doesn't work when using Vary headers but does seem to work fine for the most general case of simply needing to programmatically flush the cache after certain actions.
1 2 3 4 5 6 7 8 9 10
from django.conf import settings from django.core.cache import cache from django.utils.encoding import iri_to_uri def delete_url_cache(url): """ simple method to delete the cache for a particular URL """ key_prefix = settings.CACHE_MIDDLEWARE_KEY_PREFIX cache_key = 'views.decorators.cache.cache_header.%s.%s' % (key_prefix, iri_to_uri(url)) cache.delete(cache_key)
More like this
- Django Settings Assignment Expressions aka Walrus Operator example by webology 2 weeks, 5 days ago
- codigo alto nivel by MrRocklion 2 months, 2 weeks ago
- Load template from specific app by Krzysiek555 3 months ago
- PostgreSQL JSON subqueries by dolamroth 3 months, 1 week ago
- "Magic Link" Management Command by webology 8 months, 1 week ago