Created
January 30, 2023 16:38
-
-
Save bukowa/98b9bb84beff495ae54642b46402565f to your computer and use it in GitHub Desktop.
django don't cache static files wrapper no-cache
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 functools import wraps | |
import django.http | |
import django.views.static | |
def no_cache_static(f): | |
@wraps(f) | |
def static(*a, **kw): | |
response: django.http.response.HttpResponse = f(*a, **kw) # type: | |
response.headers["Cache-Control"] = "no-cache" | |
return response | |
return static | |
django.views.static.serve = no_cache_static(django.views.static.serve) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment