Skip to content

Instantly share code, notes, and snippets.

@bukowa
Created January 30, 2023 16:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bukowa/98b9bb84beff495ae54642b46402565f to your computer and use it in GitHub Desktop.
Save bukowa/98b9bb84beff495ae54642b46402565f to your computer and use it in GitHub Desktop.
django don't cache static files wrapper no-cache
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