概览Next.js 15 在 RSC 下的 `fetch` 可使用原生缓存策略与 `next.revalidate/tags`。通过矩阵化组合实现静态、增量与动态数据的可控更新与治理。静态缓存(长期)const data = await fetch('https://api.example.com/static', { cache: 'force-cache', next: { revalidate: 3600 } }).then(r => r.json()) 增量更新(标签治理)const data = await fetch('https://api.example.com/list', { next: { revalidate: 300, tags: ['posts'] } }).then(r => r.json()) 动态数据(实时)const data = await fetch('https://api.example.com/live', { cache: 'no-store' }).then(r => r.json()) 标签失效触发import { revalidateTag, revalidatePath } from 'next/cache' await revalidateTag('posts') await revalidatePath('/posts') 治理要点静态与增量场景使用 `revalidate` 与标签治理;实时场景使用 `no-store`。统一数据域映射为标签,降低全站重建频率。与 CDN 失效策略协同,实现端到端一致性与快速更新。验证与指标Next.js:15.0+;Node.js:20.x更新在 1–5s 内生效;静态与动态路径行为清晰可控

发表评论 取消回复