Skip to content

Instantly share code, notes, and snippets.

@AyemunHossain
Created February 24, 2022 05:34
Show Gist options
  • Save AyemunHossain/7bf21b7aa2aa4fabd0d68a7c4063787e to your computer and use it in GitHub Desktop.
Save AyemunHossain/7bf21b7aa2aa4fabd0d68a7c4063787e to your computer and use it in GitHub Desktop.
Disable Client Side Caching in Django
from django.utils.cache import add_never_cache_headers
class DisableClientSideCachingMiddleware(object):
"""
Internet Explorer / Edge tends to cache REST API calls, unless some specific HTTP headers are added by our
application.
- no_cache
- no_store
- must_revalidate
"""
def process_response(self, request, response):
add_never_cache_headers(response)
return response
#don't forget to add this on your middleware
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment