perf: replace ISR with CDN cache for versioned code and docs routes#2297
Conversation
These routes serve immutable, versioned package content (e.g. /package-code/vue/v/3.4.0/src/index.ts). With ISR enabled, every unique URL writes to durable storage — but ISR cache data shows a 145:1 write-to-read byte ratio, meaning >99% of entries are never read again. This route alone accounts for ~81% of all ISR write units. Switch to CDN cache via s-maxage headers. Vercel CDN caches are free and provide equivalent behavior for immutable content. API handler caching (defineCachedEventHandler) is unaffected. Expected impact: ~80% reduction in ISR write volume.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
2 Skipped Deployments
|
|
Hello! Thank you for opening your first PR to npmx, @JohnPhamous! 🚀 Here’s what will happen next:
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
📝 WalkthroughWalkthroughThe pull request modifies the 🚥 Pre-merge checks | ✅ 1✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
nuxt.config.ts (1)
170-175: Optional tidy-up: extract the repeated Cache-Control value into a constant.This avoids policy drift if you tweak TTL/SWR later.
♻️ Proposed refactor
const isStorybook = process.env.STORYBOOK === 'true' || process.env.VITEST_STORYBOOK === 'true' +const VERSIONED_ROUTE_CACHE_CONTROL = 'public, s-maxage=31536000, stale-while-revalidate=31536000' @@ '/package-code/**': { - headers: { 'Cache-Control': 'public, s-maxage=31536000, stale-while-revalidate=31536000' }, + headers: { 'Cache-Control': VERSIONED_ROUTE_CACHE_CONTROL }, }, '/package-docs/**': { - headers: { 'Cache-Control': 'public, s-maxage=31536000, stale-while-revalidate=31536000' }, + headers: { 'Cache-Control': VERSIONED_ROUTE_CACHE_CONTROL }, },
isr: truewiths-maxageCDN cache headers on/package-code/**and/package-docs/**/package-code/vue/v/3.4.0/src/index.ts)/package-code/alone accounts for ~81% of all ISR write units (6.4M/7.9M per 12h)s-maxage) are free and equivalent for immutable contentdefineCachedEventHandler) is unaffectedExpected impact: ~80% reduction in ISR write volume
What's lost