Skip to content

fix(webui): let the CDN hold unversioned SDK bundles for 10 minutes, not 30 days - #249

Merged
houko merged 1 commit into
mainfrom
fix/sdk-bundle-edge-cache
Oct 28, 2026
Merged

houko merged 1 commit into
mainfrom
fix/sdk-bundle-edge-cache

Conversation

@houko

@houko houko commented Oct 28, 2026

Copy link
Copy Markdown
Member

What

Unversioned SDK and survey runtime bundles (/js/forma.umd.js, /js/surveys.umd.js and their .cjs twins, without a matching ?v=) are now sent with s-maxage=600 instead of s-maxage=2592000. Browser caching (max-age=3600), stale-while-revalidate=3600, stale-if-error=86400 and the weak ETag are unchanged. Pinned and content-named URLs keep immutable.

Why

Same class of bug as the favicon in #155. These files keep fixed names because customer pages embed them, so a 30-day edge lifetime meant Cloudflare kept serving the previous release's SDK after every deploy. After 0.2.136 (Turnstile, #247) the edge still served a 27-hour-old forma.umd.js (cf-cache-status: HIT, age: 97858) without supportsTurnstile, while surveys.umd.js was already new. A Turnstile-protected survey shown by that stale loader cannot get a token, and its first response would be refused. The .cjs URLs were not affected only because Cloudflare does not cache that extension by default.

With 10 minutes at the edge, a release reaches every visitor within about 10 minutes plus the browser hour. Because of the ETag, the edge's revalidation is normally a 304, and stale-while-revalidate serves it in the background, so origin load stays negligible.

Tests

The header expectations in internal/webui (webui_test.go, sdkcache_test.go), the client API contract fixture js-surveys-umd.json and the Docker validation step are updated. go test ./internal/webui/... ./internal/clientapi/... passes on the Studio.

Rollout note

This changes only what the edge stores from now on. The copy of forma.umd.js already at Cloudflare was stored with the 30-day lifetime and must be purged once by URL: https://forma.yldm.ai/js/forma.umd.js and https://forma.yldm.ai/js/surveys.umd.js.

@houko
houko merged commit 47e6567 into main Oct 28, 2026
22 checks passed
@houko
houko deleted the fix/sdk-bundle-edge-cache branch October 28, 2026 03:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant