Created
February 24, 2022 05:34
-
-
Save AyemunHossain/7bf21b7aa2aa4fabd0d68a7c4063787e to your computer and use it in GitHub Desktop.
Disable Client Side Caching in Django
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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