Django: Stop client side caching with @never_cache

0 Comments

Sometimes you want a page to never be cached on the client side.

This could be achieved in other languages/frameworks by sending the certain HTTP headers which instruct the browser "no-cache" and "must-revalidate".

Luckily in Django, there's a nice little view decorator we can use which does just that!

1.from django.views.decorators.cache import never_cache
2. 
3.@never_cache
4.def myview(request):
5.  # Your view code here

And that's it! Hard work over.

[ Source ]

 
Copyright © Twig's Tech Tips
Theme by BloggerThemes & TopWPThemes Sponsored by iBlogtoBlog