Repository navigation
fix(web): cache-busted link-preview image URLs - #33
Merged
vlidholt merged 2 commits intoOct 22, 2026
Merged
Conversation
The app shells and the legal pages linked the Open Graph image as
/web/images/og-1.jpg, which /web/ (StaticRoute.withCacheBusting) serves as
immutable for a year: a changed image would stay stale in the CDN and in
the X and LinkedIn preview caches. Pages now link it by its content hash,
/web/images/og-1@<hash>.jpg, through Serverpod's built-in template cache
busting ({{{@/web/...}}} in a WidgetRoute with cacheBustingConfig):
- The app shells are templates: FlutterAppRoute is FlutterRoute with
/<app>/, /<app>/index.html and the SPA fallback served by AppShellRoute,
which parses the build's index.html once (again when it changes). The
build's own files stay without cache busting (icon@2x.png).
- The legal pages move to web/templates and are served by LegalPageRoute.
- specs/01 §2.4 describes the routes and the crawler caches.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The app shell templates (AppShellRoute) parse the build's index.html with whiskers, Serverpod's template engine: Serverpod's template registry only loads web/templates. Listed in specs/01 §2.1 and the dependency-rule check. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Link previews on X and LinkedIn sometimes show the wrong image. Production serves the right tags and a valid image right now (checked as Twitterbot and LinkedInBot), so the likely cause is the crawlers' caches:
og:image)./web/is served asimmutable, max-age=31536000byStaticRoute.withCacheBusting. The CDN and both crawlers cache the image by URL, so a changedog-1.jpgwould never be refetched. The route had cache busting enabled, but no page linked the hashed URLs.What
Pages now link
/web/assets by their content hash (/web/images/og-1@<hash>.jpg) through Serverpod's built-in template cache busting:{{{@/web/…}}}in aWidgetRoutewithcacheBustingConfig.web/index.htmlsayshttps://wonky.work{{{@/web/images/og-1.jpg}}}. The newFlutterAppRouteis Serverpod'sFlutterRoute(build files, SPA fallback, WASM headers), except that/<app>/,/<app>/index.htmland the SPA fallback are served byAppShellRoute. That route parses the build'sindex.htmlonce, and again when the file changes. The build's own files stay without cache busting, which would strip@…from asset names likeicon@2x.png.whiskers, the template engine Serverpod uses, is now a direct dependency of the server.web/pages/toweb/templates/and are served byLegalPageRoute. Their favicon is cache-busted too.Trade-off:
WidgetRouteanswersprivate, no-cachewithout an ETag, so browsers re-download the ~5 KB shell instead of getting a 304.After the deploy, the image gets a new URL, so crawlers and the CDN fetch it fresh. Page previews they already cached stay until they expire.
Testing
dart analyze --fatal-infosis clean.test/integration/web/flutter_app_route_test.dart(the three shell paths, HEAD, WASM headers, build files,icon@2x.png) andtest/unit/web/legal_page_route_test.dart(both pages, HEAD, the hashed image served as immutable JPEG).flutter build web --wasmof Drive keeps the placeholder in the builtindex.html.🤖 Generated with Claude Code