Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django: don't cache particular view?

Tags:

django

As per the title...

Is there a way I can force a particular view (actually a particular JSON-formatted set of results, that will be served to Ajax queries) NEVER to cache in Django?

Thanks!

like image 262
AP257 Avatar asked Feb 13 '26 11:02

AP257


1 Answers

To be sure, decorate it with @never_cache:

from django.views.decorators.cache import never_cache

@never_cache
def myview(request):
    # ...

As in The per-view cache documentation.

like image 173
Hipikat Avatar answered Feb 15 '26 16:02

Hipikat



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!