Experimental parallel prerendering
本頁內容尚未翻譯。
Type: boolean | { workers?: number }
Default: false
astro@7.4.0
新
This experimental feature makes astro build render your static pages in parallel, using multiple CPU cores at once instead of one. On sites with many pages, this can significantly reduce build times.
To enable parallel prerendering, add the flag to your Astro config:
import { defineConfig } from "astro/config";
export default defineConfig({ experimental: { parallelPrerender: true, },});Choosing the number of workers
Section titled “Choosing the number of workers”By default, Astro uses all available CPU cores but one. To use fewer, set workers to the number of CPU cores Astro should use:
import { defineConfig } from "astro/config";
export default defineConfig({ experimental: { parallelPrerender: { workers: 4, }, },});Each additional worker increases the memory used by your build. If your build runs out of memory, or does not get faster, try a lower number.
Limitations
Section titled “Limitations”Parallel prerendering currently has the following limitations:
- Pages rendered in parallel do not share module-level variables. For example, a value cached in a variable while rendering one page may not necessarily be available when rendering another.
- Pages whose
getStaticPaths()props contain unserializable values such as functions or class instances cannot be rendered in parallel. - This feature has no effect when your adapter provides its own way of prerendering pages. Among official adapters, this only applies to
@astrojs/cloudflare. Astro logs a warning during the build when the flag is ignored.