diff --git a/posthog/settings/web.py b/posthog/settings/web.py index 2c38f14937198..2116157f3f9b3 100644 --- a/posthog/settings/web.py +++ b/posthog/settings/web.py @@ -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"