Przejdź do głównej zawartości

Experimental parallel prerendering

Ta treść nie jest jeszcze dostępna w Twoim języku.

Type: boolean | { workers?: number }
Default: false

Dodane w: astro@7.4.0 Nowe

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:

astro.config.mjs
import { defineConfig } from "astro/config";
export default defineConfig({
experimental: {
parallelPrerender: true,
},
});

By default, Astro uses all available CPU cores but one. To use fewer, set workers to the number of CPU cores Astro should use:

astro.config.mjs
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.

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.
Pomóż nam Społeczność Zostań sponsorem