Monday, November 30, 2015

Re: Clear view cache using @cache_page

I don't know of a simple way. Here's something I wrote to achieve that on djangoproject.com (invalidating a cached blog post on save):

https://github.com/django/djangoproject.com/blob/90e92fd18543f95685c24f84dc5e1269a5acc38a/blog/models.py#L105-L116

Adding something to Django to help with this seems useful.

On Monday, November 30, 2015 at 12:43:29 PM UTC-5, Dimitris R wrote:
Hello, 

I am using Django 1.8.2 and caching my views using the @cache_page decorator:

@cache_page(60 * 5)
def view_name(request, obj_id):
  [...]

Is there a way to clear the cached entry programmatically, prior of the cache timeout?

Thanks, 
Dimitris

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/8a74117b-0905-4660-bd73-3e47d9c833ae%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment