Repository navigation
Serve /community from the CDN instead of a function per visit - #208
Merged
Merged
Conversation
The page read searchParams for the effect filter, which made the scene grid a dynamic hole: every visit ran a Vercel Function to render the same 48 scenes. The grid now prerenders unfiltered into the static page, and the filter reads the URL on the client and fetches the CDN-cached /api/community/scenes endpoint. The route builds as Static instead of Partial Prerender, and the middleware no longer runs on the index.
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
valebearzotti
approved these changes
Nov 6, 2026
This branch was successfully deployed
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Vercel usage for Shader Lab jumped last month:
/tools/shader-lab/communityhad 43K invocations and 16h of active CPU while visitors rose 659%.The page read
searchParamsfor the?effect=filter, so withcacheComponentsthe scene grid was a dynamic hole. The edge served the shell (toolbar, hero, skeleton), and every visit ran a function to render the same 48 scenes, filter or not.getPublicSceneswas already"use cache", so the database was mostly spared, but compute grew with every visit. The page has readsearchParamssince #118; the cost became visible when traffic spiked.Change
searchParams. The unfiltered "popular" grid prerenders into the static HTML. Publishing and deleting already invalidateCOMMUNITY_FEED_TAG.useCommunityEffectsreads?effect=on the client withuseSyncExternalStore. Chips update the URL withpushState(prefetch={false}, modifier-clicks still open a tab), and filtered pages come from/api/community/scenes, which already sendss-maxage=60, stale-while-revalidate=300.PublicSceneGridacceptsinitialScenes: nulland shows a skeleton while a filtered view loads.:path+instead of:path*, so it no longer runs on the index, where it only returnednext().Verified on a production build (
next build+next start, Playwright)○ Static(revalidate 15m) instead of◐ Partial Prerender. The HTML includes the grid and filter (262 KB, was a 36 KB shell)./communityand/community?effect=…, HTML and RSC, returnx-nextjs-cache: HITwiths-maxage=900.Tradeoffs
/community, and per-effect SEO pages stay at/community/effects/[effect].After deploy, Observability should show
/tools/shader-lab/communityinvocations near zero.🤖 Generated with Claude Code