perf(vercel): persist ISR cache across deploys with bypass token#827
perf(vercel): persist ISR cache across deploys with bypass token#827houssembaltii wants to merge 2 commits into
Conversation
Sets a 30-day ISR `expiration` so cached asset responses survive deployments (including the daily 3 AM redeploy), instead of being wiped on every build. Adds `bypassToken` wired to a new `VERCEL_BYPASS_TOKEN` env var to allow on-demand cache invalidation via the `x-prerender-revalidate` header when content changes. Drastically reduces compute spent re-running satori + sharp on the asset endpoints (`src/pages/.../assets/[__image].[__type].ts`) after each deployment. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
With `exactOptionalPropertyTypes`, the adapter's `bypassToken` field rejects `string | undefined`. Spread it conditionally so the property is omitted entirely when `VERCEL_BYPASS_TOKEN` isn't set (e.g., for local Vercel-adapter builds before the secret is configured). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
📝 WalkthroughWalkthroughThis pull request adds Vercel ISR (Incremental Static Regeneration) bypass token support to the project. A new environment variable ChangesVercel ISR Bypass Token Configuration
Estimated Code Review Effort🎯 1 (Trivial) | ⏱️ ~3 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 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 |

Explanation
30-day
expiration— accept up to 1 month of stale content, since asset inputs (events, talks, partners) rarely change after publication. Anything older auto-refreshes on next access.bypassToken— when content changes (e.g., rename a speaker, swap a partner logo) and we want the affected asset refreshed sooner, invalidate the specific URL with a HEAD request carrying the token:curl -I -H "x-prerender-revalidate: $BYPASS_TOKEN" https://forkit-community-git-houssembaltii-isr-cache-c79541-bearstudio.vercel.app/events/2026-france-rouen/assets/save-the-date-insta.jpgPer-URL only, no wildcards. The next visit regenerates the image.
Bulk invalidation (when a change affects every asset) — e.g., adding a new banner to all of them. Curling hundreds of URLs is impractical, so:
expirationto a short value (e.g.,60seconds).expiration: 60 * 60 * 24 * 30.Summary by CodeRabbit