Skip to content

Commit

Permalink
fix: static files served with different vary headers (#26532)
Browse files Browse the repository at this point in the history
  • Loading branch information
pauldambra authored Nov 29, 2024
1 parent 052841f commit 68402d1
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions posthog/settings/web.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,19 @@
]
STATICFILES_STORAGE = "whitenoise.storage.ManifestStaticFilesStorage"


def add_vary_headers(headers, _path, _url):
"""
we might serve static content on multiple domains, so we need to vary on Origin
as well as accept-encoding to avoid caching issues
see: https://github.com/evansd/whitenoise/blob/b3d250fd17da0e280d58b6dc4935c4573ebe8b55/docs/django.rst?plain=1#L392-L422
which says: The function should not return anything; changes should be made by modifying the headers dictionary directly.
"""
headers["Vary"] = "Origin, Accept-Encoding"


WHITENOISE_STATIC_HEADERS = add_vary_headers

AUTH_USER_MODEL = "posthog.User"

LOGIN_URL = "/login"
Expand Down

0 comments on commit 68402d1

Please sign in to comment.