Token导航 LogoToken导航TokenDH.com
前端设计执行命令github未标认证来源可访问许可证需确认审计通过

nextjs-cachingNext.js caching 前端

Agent Skill

用于辅助前端页面、组件、样式和交互逻辑的开发与维护。它适合让 Agent 生成或审查 React、Next.js、Vue、Tailwind、CSS 等相关代码,整理组件结构,或定位布局和性能问题。使用时需要结合项目现有设计系统、路由和构建方式,避免只生成孤立片段;涉及页面改动时,应配合本地预览和构建检查确认视觉效果。

总安装

1,129

周安装

48

GitHub Stars

16

下载量

396
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:nextjs-caching(Next.js caching 前端)
来源仓库:https://github.com/goncy/skills
仓库路径:skills/nextjs-caching
安装命令:
npx skills add https://github.com/goncy/skills --skill nextjs-caching
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/goncy/skills --skill nextjs-caching

简介

用于辅助前端页面、组件和样式开发。nextjs-caching 属于前端设计类 Skill,可作为该场景下的辅助能力补充。

  • 适合生成或审查 React、Next.js 相关代码。
  • 需要结合项目现有设计系统和路由方式使用。
  • 避免生成孤立片段,涉及页面改动应配合预览检查。
  • 建议先确认构建方式和视觉效果再实施改动。

SKILL.md

Next.js Caching

Expert guidance on Next.js caching mechanisms, ISR patterns, and common pitfalls.

Core Concepts

"use cache" Directive

Mark components or functions as cacheable. The directive does not cache immediately—it marks the output for caching at build time.

"use cache"
export default function MyComponent() {
  // Output cached at build time
}

When applied to a page's main component, creates ISR-like behavior where the entire output is cached (no partial caching).

Automatic Static Rendering

Next.js renders top-to-bottom until encountering dynamic APIs, then creates a "dynamic hole." No explicit "use cache" required unless forcing ISR behavior for the entire page.

Cached functions are NOT considered dynamic and won't create holes.

Two-Phase Rendering

  1. Warmup render (prospective): Detects dynamic API usage. Anything not resolving in a microtask is considered dynamic.
  2. Final render: Captures actual output for pre-rendering.

Revalidation APIs

revalidateTag vs updateTag

  • revalidateTag: Revalidates in stale-while-revalidate manner when used in server actions. Serves stale content while fetching fresh data.
  • updateTag: Read-your-own-writes pattern, purging previous cache immediately. Cannot be used in route handlers.

Note: Despite the name, revalidatePath is actually revalidateTag under the hood—the argument is (kind of) a path.

connection() Replacement

Use connection() as a replacement for unstable_noStore() to mark functions as dynamic.

ISR Patterns

Suspense Boundaries with "use cache"

Components with "use cache" + Suspense boundaries work like ISR:

  1. First request triggers Suspense boundary
  2. Content displays and result caches
  3. Subsequent requests serve cached content

To keep Suspense dynamic, move static content to separate cached components.

Accessing Cached Values Across Boundaries

Cache function outputs (not just components) to reuse values between layouts and pages. Call the cached function again to retrieve the value.

Partial Page Caching

For mixed static/dynamic pages:

  • Leave page without "use cache"
  • Cache individual components
  • Wrap dynamic components in Suspense
  • Alternative: Use parallel routes

Dynamic Routes & generateStaticParams

Critical Requirements

Export at least one param in generateStaticParams to generate static shells and enable ISR behavior.

export function generateStaticParams() {
  return [{ id: 'placeholder' }] // Handle this case in render
}

Without generateStaticParams, dynamic pages fail due to missing Suspense above param reads.

Workaround: Add loading.tsx or empty Suspense around body to block the server.

Cache Persistence

unstable_cache vs "use cache: remote"

  • unstable_cache: Persists across deployments
  • "use cache: remote": Does NOT persist across deployments

Cache Snapshots at Build Time

Cacheable functions snapshot when called at build time. Using "use cache"'d functions in dynamic components only guarantees cache hits if the snapshot was captured at build time. Otherwise serves from in-memory cache.

Performance & Infrastructure

Short Cache Behavior

Caches with stale < 30 seconds are "short cache" and excluded from runtime prefetch.

Edge Proxy Resilience

The proxy returning static shells runs on edge. Returns shell immediately and continues request for dynamic content. If a region fails, proxy continues working.

unstable_cache Performance

unstable_cache functions are considered instant for rendering purposes.

Debugging

Verifying Static Pages

Build logs sometimes show ppr for static pages. Most reliable verification: check x-nextjs-cache: HIT header in document request.

Layout "use cache" Caveat

Setting "use cache" in layout without setting it on page does NOT make the page static.

References

  • references/detailed-guide.md: Comprehensive examples and detailed explanations for all caching patterns. Read when implementing specific caching strategies or debugging cache behavior.

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

39.33%
按下载量换算156

Claude

30.39%
按下载量换算120

Cursor

17.93%
按下载量换算71

Gemini CLI

9.28%
按下载量换算37

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

执行命令

安装流程涉及命令执行,可能通过 npx skills add https://github.com/goncy/skills --skill nextjs-caching 联网下载 Skill 或依赖。用户安装前应确认命令来源、仓库内容和执行环境。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills