Communitygithub.com

ComeOnOliver/skillshub

Next.js 的四層快取架構。在配置請求記憶化、資料快取、完整路由快取或路由器快取時使用。 (觸發條件:**/page.tsx, **/layout.tsx, **/action.ts, unstable_cache, revalidateTag, Router Cache, Data Cache)

skillshub 是什麼?

這個技能提供了一個關於 Next.js 應用程式中四種不同快取層級的全面指南。它能幫助開發者理解並正確配置請求記憶化、資料快取、完整路由快取和路由器快取,以防止過時資料的錯誤。此技能涵蓋了 Next.js 15+ 和 16+ 的最佳實務,包括使用 `'use cache'` 指令進行宣告式快取、使用 `revalidateTag` 進行精確的失效處理,以及使用 `Suspense` 搭配串流來提升渲染效能。它也提供了常見反模式的警示,例如避免在較新版本中使用 `unstable_cache`,並強調整體快取策略中標籤化的重要性。它支援各種 Next.js 平台,並作為開發者優化快取的參考指南。

相容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/ComeOnOliver/skillshub/tree/HEAD/skills/HoangNguyen0403/agent-skills-standard/nextjs-caching

在你喜歡的 AI 中提問

開啟一個已預先載入此 Agent Skill 的新對話。

說明文件

快取架構

優先級:P1 (高)

Next.js 有四個不同的快取層。了解它們可以防止過時資料的錯誤。

實作指南

  • Next.js 15+ 標準:在 API 呼叫中使用 fetch 搭配 revalidate: number 或 cache: 'force-cache'。對於自訂資料儲存,請使用 unstable_cache 或新的 'use cache'(實驗性)。
  • 層級:區分 資料快取(跨請求持久化)和 請求記憶化(專屬於 React 生命週期)。使用 React 的 cache() 來消除單次渲染中的重複擷取。
  • 失效:在資料變更後使用 revalidatePath('/'),或使用 revalidateTag('tag-name') 進行更精細的快取清除。
  • 客戶端快取:了解路由器快取(客戶端記憶體內)及其 30 秒到數分鐘的生命週期。使用 router.refresh() 清除它。
  • 靜態資源:利用 generateStaticParams 在建置時預先渲染靜態路由。使用 ISR(增量靜態再生) 處理定期更新的內容。
  • 串流:將 Suspense 與 fetch 觸發條件結合,防止慢速資料阻塞整個頁面的渲染。
  • Next.js 16+:在可用情況下,優先使用 'use cache' 和 cacheLife() 而不是 revalidate: number,以實現確定性快取。
層級位置控制方式
請求記憶化伺服器React cache()
資料快取伺服器'use cache', revalidateTag
完整路由快取伺服器靜態預先渲染
路由器快取客戶端router.refresh()

實作細節

請參閱快取元件與 PPR 以了解詳細的金鑰產生、閉包限制和失效策略。

反模式

  • Next.js 16+ 中不使用 unstable_cache:請改用 'use cache' 指令搭配 cacheLife()。
  • 不對伺服器資料使用 router.refresh():優先使用 revalidateTag() 進行目標式快取清除。
  • 不在路由層級快取使用者特定資料:使用 'use cache' 將個人資料包裹在 <Suspense> 中。
  • 不為沒有標籤的快取設定長時間存活:為標籤分配 cacheTag() 以實現細粒度的失效控制。

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

ComeOnOliver/skillshub

Create stunning, animation-rich HTML presentations from scratch or by converting PowerPoint files. Use when the user wants to build a presentation, convert a PPT/PPTX to web, or create slides for a talk/pitch. Helps non-designers discover their aesthetic through visual exploration rather than abstract choices.

ComeOnOliver/skillshub

Next.js 16+ 和 Turbopack — 增量打包、文件系统缓存、开发速度,以及何时使用 Turbopack 与 webpack。

ComeOnOliver/skillshub

SwiftUI architecture patterns, state management with @Observable, view composition, navigation, performance optimization, and modern iOS/macOS UI best practices.

ComeOnOliver/skillshub

See, Understand, Act on video and audio. See- ingest from local files, URLs, RTSP/live feeds, or live record desktop; return realtime context and playable stream links. Understand- extract frames, build visual/semantic/temporal indexes, and search moments with timestamps and auto-clips. Act- transcode and normalize (codec, fps, resolution, aspect ratio), perform timeline edits (subtitles, text/image overlays, branding, audio overlays, dubbing, translation), generate media assets (image, audio, video), and create real time alerts for events from live streams or desktop capture.

ComeOnOliver/skillshub

AI-assisted video editing workflows for cutting, structuring, and augmenting real footage. Covers the full pipeline from raw capture through FFmpeg, Remotion, ElevenLabs, fal.ai, and final polish in Descript or CapCut. Use when the user wants to edit video, cut footage, create vlogs, or build video content.

ComeOnOliver/skillshub

Next.js 15 애플리케이션을 위한 프론트엔드 개발 가이드라인. React 19, TypeScript, Shadcn/ui, Tailwind CSS를 사용한 모던 패턴. Server Components, Client Components, App Router, 파일 구조, Shadcn/ui 컴포넌트, 성능 최적화, TypeScript 모범 사례 포함. 컴포넌트, 페이지, 기능 생성, 데이터 페칭, 스타일링, 라우팅, 프론트엔드 코드 작업 시 사용.

ComeOnOliver/skillshub

Provides Tamagui patterns for config v4, compiler optimization, styled context, and cross-platform styling. Must use when working with Tamagui projects (tamagui.config.ts, @tamagui imports).

ComeOnOliver/skillshub

Create distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.

ComeOnOliver/skillshub

Create high-converting, visually distinctive landing pages. Use when building marketing pages, product launches, SaaS homepages, or any single-page conversion-focused website. Guides section-by-section composition with anti-AI-slop principles.

ComeOnOliver/skillshub

Auto-loaded context for Portfolio Buddy 2 development. Use for ANY task involving: React 19 development, TypeScript, portfolio analysis features, metrics calculations, trading strategy comparison, or working with the Portfolio Buddy 2 codebase. Contains tech stack, known issues, and architectural constraints.

ComeOnOliver/skillshub

Next.js development tooling via MCP. Inspect routes, components, build info, and debug Next.js apps. Use when working on Next.js applications, debugging routing, or inspecting app structure. NOT for general React or non-Next.js projects.

ComeOnOliver/skillshub

Implement UI using Shadcn MCP (atoms/theme) and 21st.dev MCP (complex sections). Use when adding buttons, layouts, or generating landing pages.

ComeOnOliver/skillshub

A conceptual skill for building an API client in Next.js that handles JWT tokens

ComeOnOliver/skillshub

Best practices and patterns for Next.js App Router, Server Actions, and Routing in this project.

ComeOnOliver/skillshub

The Design System, Theme, and UX rules for the Physical AI Hub.

ComeOnOliver/skillshub

Comprehensive frontend development skill for building modern, performant web applications using ReactJS, NextJS, TypeScript, Tailwind CSS. Includes component scaffolding, performance optimization, bundle analysis, and UI best practices. Use when developing frontend features, optimizing performance, implementing UI/UX designs, managing state, or reviewing frontend code.

ComeOnOliver/skillshub

This document captures learnings from fixing keyboard navigation issues when floating components (Select, DropdownMenu, Popover) have CSS open/close animations.

ComeOnOliver/skillshub

Build Next.js 16 applications with correct patterns and distinctive design. Use when creating pages, layouts, dynamic routes, upgrading from Next.js 15, or implementing proxy.ts. Covers breaking changes (async params/searchParams, Turbopack, cacheComponents) and frontend aesthetics. NOT when building non-React or backend-only applications.

ComeOnOliver/skillshub

Comprehensive Framer Motion animation library for React. Covers motion components, variants, gestures, page transitions, and scroll animations. Use when adding animations to React/Next.js applications.

ComeOnOliver/skillshub

Build interfaces that resonate, not just render. This skill enforces bold, intentional

相關技能