Skip to content

perf: increase ISR revalidation intervals for package and API routes#2298

Merged
danielroe merged 1 commit intonpmx-dev:mainfrom
JohnPhamous:perf/increase-isr-revalidation-intervals
Mar 27, 2026
Merged

perf: increase ISR revalidation intervals for package and API routes#2298
danielroe merged 1 commit intonpmx-dev:mainfrom
JohnPhamous:perf/increase-isr-revalidation-intervals

Conversation

@JohnPhamous
Copy link
Copy Markdown
Contributor

@JohnPhamous JohnPhamous commented Mar 27, 2026

  • /api/**: 60s → 300s
  • /__og-image__/**: 60s → 3600s
  • /package/** + payload routes: 60s → 300s

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 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.

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.
@vercel
Copy link
Copy Markdown

vercel bot commented Mar 27, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
npmx.dev Ready Ready Preview, Comment Mar 27, 2026 5:49pm
2 Skipped Deployments
Project Deployment Actions Updated (UTC)
docs.npmx.dev Ignored Ignored Preview Mar 27, 2026 5:49pm
npmx-lunaria Ignored Ignored Mar 27, 2026 5:49pm

Request Review

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 27, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 27, 2026

📝 Walkthrough

Walkthrough

The pull request modifies ISR expiration window configurations in nuxt.config.ts. The ISR cache duration for API routes and package-related payload endpoints is increased from 60 seconds to 300 seconds. The OG image route rule ISR expiration is separately increased to 3600 seconds. These adjustments apply to multiple route patterns including the catch-all API route rule and versioned package payload paths. No public type or function declarations were altered; only configuration values changed.

🚥 Pre-merge checks | ✅ 1
✅ Passed checks (1 passed)
Check name Status Explanation
Description check ✅ Passed The pull request description clearly explains the ISR revalidation interval changes across multiple routes and provides detailed context about the performance impact and user experience implications.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 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".


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: ce7aca87-c77a-47d4-aa86-eb269768cf9a

📥 Commits

Reviewing files that changed from the base of the PR and between 873562d and 1df9609.

📒 Files selected for processing (1)
  • nuxt.config.ts

@danielroe danielroe added this pull request to the merge queue Mar 27, 2026
Merged via the queue into npmx-dev:main with commit c451765 Mar 27, 2026
23 checks passed
@github-actions github-actions bot mentioned this pull request Mar 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants