Django: Stop client side caching with @never_cache

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!

from django.views.decorators.cache import never_cache

@never_cache
def myview(request):
# Your view code here

And that's it! Hard work over.

[ Source ]

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