Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

perf(devex): raise whitenoise max-age for non-hashed static (#70375)

Julian Bez6d796833148b
diff --git a/posthog/settings/web.py b/posthog/settings/web.py
index 6b96cb02ad9d..1c626a357ad0 100644
--- a/posthog/settings/web.py
+++ b/posthog/settings/web.py
@@ -419,6 +419,14 @@ def static_varies_origin(headers, path, url):
WHITENOISE_ADD_HEADERS_FUNCTION = static_varies_origin
+# Non-hashed static files (notably the posthog-js SDK bundles served to
+# end-user browsers) otherwise fall back to whitenoise's 60s default and
+# generate constant 304 revalidation churn (~a third of /static traffic).
+# Hashed manifest assets are unaffected — whitenoise already serves those
+# with far-future caching. One hour bounds how long a client that does not
+# cache-bust can hold a stale SDK bundle after a release.
+WHITENOISE_MAX_AGE = get_from_env("WHITENOISE_MAX_AGE", 3600, type_cast=int)
+
# Per-IP signup throttle rate (see posthog.rate_limit.SignupIPThrottle). Overridable per-env so
# non-prod (e.g. dev deploy smoke-tests) can raise it without weakening the prod default.
SIGNUP_IP_THROTTLE_RATE = get_from_env("SIGNUP_IP_THROTTLE_RATE", "5/day")