perf: increase ISR revalidation intervals for package and API routes#2298
Conversation
Current 60s ISR triggers background revalidation every minute for active URLs. Server-side data caches (package-meta: 300s, downloads: 3600s, files: 1y) outlive this — most revalidations produce identical HTML and the ISR write is skipped, but the function still executes. Align page ISR (300s) with the fastest handler cache to eliminate redundant revalidation invocations. OG images increased to 3600s (stable per package version). API catch-all increased to 300s (explicit overrides are unaffected). Expected impact: ~80% fewer time-based revalidations, ~25-30% compute reduction.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
2 Skipped Deployments
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
📝 WalkthroughWalkthroughThe pull request modifies ISR expiration window configurations in 🚥 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)
164-168: Consider named TTL constants to reduce magic numbers across route rules.This change is correct, but extracting shared durations would improve readability and future tuning.
♻️ Optional tidy-up
+const ISR_5_MINUTES = 5 * 60 +const ISR_1_HOUR = 60 * 60 + routeRules: { - '/api/**': { isr: 300 }, + '/api/**': { isr: ISR_5_MINUTES }, ... - '/__og-image__/**': getISRConfig(3600), + '/__og-image__/**': getISRConfig(ISR_1_HOUR), ... - '/package/**': getISRConfig(300, { fallback: 'html' }), - '/package/:name/_payload.json': getISRConfig(300, { fallback: 'json' }), - '/package/:name/v/:version/_payload.json': getISRConfig(300, { fallback: 'json' }), - '/package/:org/:name/_payload.json': getISRConfig(300, { fallback: 'json' }), - '/package/:org/:name/v/:version/_payload.json': getISRConfig(300, { fallback: 'json' }), + '/package/**': getISRConfig(ISR_5_MINUTES, { fallback: 'html' }), + '/package/:name/_payload.json': getISRConfig(ISR_5_MINUTES, { fallback: 'json' }), + '/package/:name/v/:version/_payload.json': getISRConfig(ISR_5_MINUTES, { fallback: 'json' }), + '/package/:org/:name/_payload.json': getISRConfig(ISR_5_MINUTES, { fallback: 'json' }), + '/package/:org/:name/v/:version/_payload.json': getISRConfig(ISR_5_MINUTES, { fallback: 'json' }),As per coding guidelines, "Use clear, descriptive variable and function names".
/api/**: 60s → 300s/__og-image__/**: 60s → 3600s/package/**+ payload routes: 60s → 300sCurrent 60s ISR triggers background revalidation every minute for active URLs. Server-side data caches (package-meta: 300s, downloads: 3600s, files: 1y) outlive this — most revalidations produce identical HTML and the ISR write is skipped, but the function still executes on each cycle.
Aligning page ISR (300s) with the fastest handler cache eliminates redundant revalidation invocations. OG images set to 3600s (stable per package version). API catch-all set to 300s (explicit overrides unaffected).
Expected impact: ~80% fewer time-based revalidations, ~25-30% compute reduction
What the user experiences
Package page content may be up to 5 min stale (was 1 min). Since npm metadata changes on publish (typically days/weeks) and download counts aggregate daily, this is imperceptible.