Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: static files served with different vary headers #26532

Merged
merged 1 commit into from
Nov 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading