[Optimization]: Bundle Splitting, API Caching & UX — Cycle Feb 18#42
Open
Eli5DeFi wants to merge 1 commit intofeature/prophecy-nft-galleryfrom
Open
[Optimization]: Bundle Splitting, API Caching & UX — Cycle Feb 18#42Eli5DeFi wants to merge 1 commit intofeature/prophecy-nft-galleryfrom
Eli5DeFi wants to merge 1 commit intofeature/prophecy-nft-galleryfrom
Conversation
… pages - next.config.js: add Web3 fallbacks, scrollRestoration, AVIF-first images, per-route cache headers, remove duplicate .mjs config - Leaderboards page: dynamic import with skeleton loader (better FCP/TTI) - Lore dynamic pages: add force-dynamic + ISR fetch revalidate (300s) - API routes: in-memory cache (5min TTL) for stories, houses, protocols, leaderboards - API routes: add force-dynamic where request.url/searchParams used - Dashboard: 285kB → 272kB (-4.6%), Lore: 242kB → 229kB (-5.4%)
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.
Optimizations
🚀 Frontend
Lazy-loaded Leaderboards component (biggest UX win)
/leaderboards(heavy 562-line component deferred)Code splitting for vendor chunks
walletchunk (long-lived cache)chartschunk (only loaded on chart pages)uichunkreactchunkISR + Fetch caching for lore pages
lore/houses-dynamic+lore/protocols-dynamic: Changed fromcache: 'no-store'→next: { revalidate: 300 }🗄️ Backend / API
In-memory cache added to expensive routes (5-min TTL via
MemoryCache)GET /api/stories— cache per query params comboGET /api/lore/houses— 5min cache, prevents repeated full House queriesGET /api/lore/protocols— 5min cache per filter combinationGET /api/leaderboards— 5min cache per category/timeframe (heavy aggregation queries)Added
X-Cache: HIT/MISSheaders for observabilityFixed API route static generation warnings
export const dynamic = 'force-dynamic'to all routes usingrequest.url/searchParams⚙️ Config
Removed duplicate
next.config.mjs(renamed to.bak)next.config.jsis used; having both caused confusionnext.config.jshas the superior configuration (splitChunks, optimizePackageImports)next.config.js improvements
compress: trueexplicitlyminimumCacheTTL: 60s → 3600s (images now cached 1 hour)scrollRestoration: trueexperimental flag (back/forward scroll position)fs,net,tls)Metrics (Before/After)
*Leaderboards total JS similar, but lazy-loaded → page is interactive much faster (skeleton shows immediately)
Testing
pnpm build)Impact