Unverified Commit 7e82ad1c authored by David Alexandru Ilie's avatar David Alexandru Ilie Committed by GitHub

docs: explain Cache Components config parity

parent 7a4884e6
...@@ -73,6 +73,8 @@ export default nextConfig ...@@ -73,6 +73,8 @@ export default nextConfig
> **Good to know:** If you were using `experimental.dynamicIO` or `experimental.useCache`, `cacheComponents` replaces them. See the [version 16 upgrade guide](/docs/app/guides/upgrading/version-16#experimentaldynamicio-and-experimentalusecache). > **Good to know:** If you were using `experimental.dynamicIO` or `experimental.useCache`, `cacheComponents` replaces them. See the [version 16 upgrade guide](/docs/app/guides/upgrading/version-16#experimentaldynamicio-and-experimentalusecache).
When self-hosting with `next start`, make sure `cacheComponents` resolves to the same value at build time and runtime. This is especially important for multi-stage Docker images. See [Cache Components configuration](/docs/app/guides/self-hosting#cache-components-configuration).
After enabling the flag, route segments that still export `dynamic`, `revalidate`, or `fetchCache` will error. Start by replacing those configs. The sections below explain what to do for each one. After enabling the flag, route segments that still export `dynamic`, `revalidate`, or `fetchCache` will error. Start by replacing those configs. The sections below explain what to do for each one.
## Opting out of validation ## Opting out of validation
......
...@@ -82,6 +82,14 @@ This allows you to use a singular Docker image that can be promoted through mult ...@@ -82,6 +82,14 @@ This allows you to use a singular Docker image that can be promoted through mult
> >
> - You can run code on server startup using the [`register` function](/docs/app/guides/instrumentation). > - You can run code on server startup using the [`register` function](/docs/app/guides/instrumentation).
## Cache Components configuration
When using [`cacheComponents`](/docs/app/api-reference/config/next-config-js/cacheComponents), `next build` and `next start` must resolve it to the same value. A production build created with Cache Components enabled cannot be started with Cache Components disabled, or vice versa. Next.js exits during startup when it detects a mismatch.
For a multi-stage Docker image that runs `next start`, copy the same `next.config.*` file into the runtime image along with the build output. Alternatively, use [`output: 'standalone'`](/docs/app/api-reference/config/next-config-js/output#automatically-copying-traced-files). The generated `server.js` includes the resolved Next.js configuration, so you do not need to copy `next.config.*` separately.
This does not change the runtime environment variable behavior described above. One Docker image can still be promoted through multiple environments with different runtime values.
## Caching and ISR ## Caching and ISR
Next.js can cache responses, generated static pages, build outputs, and other static assets like images, fonts, and scripts. Next.js can cache responses, generated static pages, build outputs, and other static assets like images, fonts, and scripts.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment