Skip to content

perf(vercel): persist ISR cache across deploys with bypass token#827

Open
houssembaltii wants to merge 2 commits into
mainfrom
houssembaltii/isr-cache-expiration
Open

perf(vercel): persist ISR cache across deploys with bypass token#827
houssembaltii wants to merge 2 commits into
mainfrom
houssembaltii/isr-cache-expiration

Conversation

@houssembaltii

@houssembaltii houssembaltii commented May 20, 2026

Copy link
Copy Markdown
Contributor

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

    Per-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:

    1. Push a commit lowering expiration to a short value (e.g., 60 seconds).
    2. Let the deploy go out; cached entries become stale within ~1 minute of next access.
    3. Push another commit restoring expiration: 60 * 60 * 24 * 30.

Summary by CodeRabbit

  • Chores
    • Configured Incremental Static Regeneration (ISR) for deployments with a 30-day cache expiration window.
    • Added support for deployment bypass token configuration.

Review Change Stack

houssembaltii and others added 2 commits May 20, 2026 15:42
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>
@vercel

vercel Bot commented May 20, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
forkit-community Ready Ready Preview, Comment May 20, 2026 3:58pm

Request Review

@coderabbitai

coderabbitai Bot commented May 20, 2026

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

This pull request adds Vercel ISR (Incremental Static Regeneration) bypass token support to the project. A new environment variable VERCEL_BYPASS_TOKEN is declared in .env.example and conditionally wired into the Astro Vercel adapter configuration with a 30-day cache expiration.

Changes

Vercel ISR Bypass Token Configuration

Layer / File(s) Summary
ISR bypass token environment configuration
env.example, astro.config.mjs
Environment variable VERCEL_BYPASS_TOKEN is added to .env.example and conditionally included in the Vercel adapter's ISR configuration with explanatory comments and a 30-day cache expiration setting.

Estimated Code Review Effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

A token for the Vercel winds to blow,
Thirty days of cache to help things flow,
The bypass whispers secrets to the ISR,
Clean config updates, no fuss nor stir! 🐰✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: configuring Vercel ISR to persist cache across deployments using a bypass token mechanism.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch houssembaltii/isr-cache-expiration

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.

@houssembaltii

Copy link
Copy Markdown
Contributor Author

example of the response when invalidating an asset .
x-vercel-cache: Revalidated
image

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.

1 participant