# NextJs-Four-Service-Render-Demo **Repository Path**: leeyamaster/next-js-four-service-render-demo ## Basic Information - **Project Name**: NextJs-Four-Service-Render-Demo - **Description**: NextJs四种服务端渲染Demo - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-09-01 - **Last Updated**: 2025-09-01 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README This is a [Next.js](https://nextjs.org) project bootstrapped with [`create-next-app`](https://nextjs.org/docs/app/api-reference/cli/create-next-app). ## Getting Started First, run the development server: ```bash npm run dev # or yarn dev # or pnpm dev # or bun dev ``` Open [http://localhost:3000](http://localhost:3000) with your browser to see the result. You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file. This project uses [`next/font`](https://nextjs.org/docs/app/building-your-application/optimizing/fonts) to automatically optimize and load [Geist](https://vercel.com/font), a new font family for Vercel. ## Learn More To learn more about Next.js, take a look at the following resources: - [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API. - [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial. You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js) - your feedback and contributions are welcome! ## Deploy on Vercel The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js. Check out our [Next.js deployment documentation](https://nextjs.org/docs/app/building-your-application/deploying) for more details. http://localhost:3000/csr — 客户端渲染 http://localhost:3000/ssr?id=5 — 服务端渲染 http://localhost:3000/ssg/2 — 静态生成(构建时已存在) http://localhost:3000/isr/99 — 首次 SSR,10 秒后缓存更新(生产环境用 npm run build && npm start 测试) npm run dev 已经能完整体验 CSR / SSR / SSG / ISR,但表现略有差异: | 模式 | Dev 环境行为 | 生产(build & start)差异 | | ------- | ---------------------------------------------------------------------- | ------------------- | | **CSR** | 完全一致 | 无差异 | | **SSR** | 每次刷新重新 `fetch` | 一致 | | **SSG** | 仅预渲染 `generateStaticParams` 指定路径;其余路径第一次访问时 **动态 SSR**(称为 **Dev SSG**) | 全部预渲染 | | **ISR** | 预渲染路径立即缓存;未命中路径 **动态 SSR**,**不会** 10 秒后再生成 | 10 秒后缓存更新 | | 维度 | CSR | SSR | SSG | ISR | | ----------- | ------------------- | -------------- | ------------- | ----------------------- | | **渲染时机** | 浏览器执行 JS 时 | 每次请求服务器现算 | 构建时一次性算好 | 构建时算一次,之后按间隔或触发器 **再算** | | **数据新鲜度** | 最实时 | 最实时 | 构建时刻快照 | 快照+定时更新 | | **首屏 TTFB** | 慢(空 html → js → 数据) | 快(服务器直接给 html) | 最快(静态文件) | 快(静态文件或首次 SSR) | | **CDN 缓存** | 不缓存 html | 可缓存 html | 完全缓存 | 缓存 html,定时失效 | | **适用场景** | 管理后台 / 实时图表 | 个性化内容(千人千面) | 宣传页 / 博客 / 文档 | 商品详情 / 新闻列表 | | **部署复杂度** | 一个静态包 | 需要 Node 运行时 | 纯静态 | 静态 + 按需构建 | 一句话记忆 CSR = 浏览器算 SSR = 服务器每次算 SSG = 构建时算一次 ISR = 构建时算一次,后续按策略再算 SSG:一次打包,永远不变,除非重新部署。 ISR:先按 SSG 打包,之后 定时或按需再生成新版本,用户无需等你重新部署。