未验证 提交 cf9762e0 编写于 作者: J JJ Kasper 提交者: GitHub

Expand automatic pre-rendering docs (#7702)

* Expand automatic pre-rendering docs

* Apply suggestions from code review
Co-Authored-By: NLuis Fernando Alvarez D. <luis@zeit.co>
上级 3aed76fa
......@@ -1764,11 +1764,13 @@ module.exports = {
## Automatic Pre-rendering
Next.js will automatically choose between a `dynamic` or `static` page at build time with `next build`, this is based on whether or not `getInitialProps` is set in the page, if set Next.js will assume that your page is `dynamic`, or `static` otherwise.
Next.js will automatically detect if a page is `static` at build time with `next build`, this is currently based on whether or not `getInitialProps` is set in the page, if set Next.js will assume that your page is not `static` and requires a server or lambda bundle.
This allows Next.js to only do server side render of pages that rely on dynamic data, and to pre-render non dynamic pages.
This allows Next.js to automatically replace server bundles for static pages with static HTML files. This has numerous benefits like better ability to be cached, cheaper runtime costs, and more.
> **Note**: If you have a custom `App` with a custom `getInitialProps` then all your pages will be dynamic, except for AMP pages.
During the build, when we automatically pre-render a page, for example `/about`, the server bundle in `.next/server/static/${BUILD_ID}/about.js` will be automatically replaced with `.next/server/static/${BUILD_ID}/about.html`. Then when you run `next start` or deploy with [now](https://zeit.co/now) the HTML file will be automatically served instead of requiring a server-side render each request.
> **Note**: If you have a [custom `App`](#custom-app) with a custom `getInitialProps` then this optimization will be disabled.
## Production deployment
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册