在 Vercel 上为 Astro 提供按需 ISR

In this post we will go over how to set on-demand incremental static regeneration for your Astro website when deploying to Vercel.

在这篇文章中,我们将讨论如何在将 Astro 网站部署到 Vercel 时设置按需增量静态再生。

Overview[

概述[

](https://www.shawn.so/#overview)

](https://www.shawn.so/#overview)

Here is what we will go over in this blog post:

在这篇博客文章中,我们将讨论以下内容:

  1. What is ISR and what is on-demand ISR
  2. 什么是 ISR,什么是按需 ISR
  3. How to set up on-demand ISR for Astro on Vercel
  4. 如何在 Vercel 上为 Astro 设置按需 ISR
  5. How to on-demand invalidate a cached static page
  6. 如何按需使缓存的静态页面失效
  7. If you wanna know how to deploy your Astro project to Vercel you can go over the steps in my other post in the deploying our blog to Vercel section.
  8. 如果你想知道如何将你的 Astro 项目部署到 Vercel,可以查看我在 将我们的博客部署到 Vercel 部分中的步骤。

What is ISR?[

什么是 ISR?[

](https://www.shawn.so/#what-is-isr)

](https://www.shawn.so/#what-is-isr)

ISR or incremental static regenration is a flow that allows you to update static content like blog posts or GET API endpoints without having to rebuild or redeploy your entire website in order to serve updated static content from your cache, usually from a CDN.

ISR 或增量静态再生是一种流程,允许您更新静态内容,如博客文章或 GET API 端点,而无需重建或重新部署整个网站,以便从缓存中提供更新的静态内容,通常来自 CDN。

What is On-Demand ISR?[

什么是按需ISR?[

](https://www.shawn.so/#what-is-on-demand-isr)

](https://www.shawn.so/#what-is-on-demand-isr)

For ISR you’d usually set TTL (time to live) like 1 hour or 1 day, after which the content would be automatically invalidated and the subsequent request would trigger a rebuild of the page and caching of the fresh build, serving directly from cache for subsequent requests.

对于ISR,你通常会设置TTL(生存时间)为1小时或1天,之后内容将自动失效,随后的请求将触发页面的重建和新构建的缓存,后续请求将直接从缓存中提供服务。

With on-demand ISR you get additional control over your cache in the sense that now you can on-demand invalidate it and trigger a fresh build even if the TTL hasn’t been reached yet.

通过按需ISR,你可以对缓存有额外的控制,因为现在你可以按需使其失效并触发新的构建,即使TTL尚未到达。

What Use Cases is On-Demand ISR Good For?[

按需 ISR 适合哪些用例?[

](https://www.shawn.so/#what-use-cases-is-on-demand-isr-good-for)

](https://www.shawn.so/#what-...

开通本站会员,查看完整译文。

Home - Wiki
Copyright © 2011-2025 iteam. Current version is 2.148.2. UTC+08:00, 2025-12-12 08:07
浙ICP备14020137号-1 $Map of visitor$