iTranslated by AI
The content below is an AI-generated translation. This is an experimental feature, and may contain errors. View original article
🌐
Preventing Duplicate HTTP Requests During Next.js Builds
Next.js has a mechanism called Request Memoization, where fetch is automatically memoized to prevent duplicate requests.
However, when building multiple SSG pages that include the same HTTP requests, duplicate requests are sent, likely because the SSG processes run in parallel.
If you want to prevent duplicate HTTP requests during the build, adding the following configuration to next.config.js will make the build process single-threaded, and fetch will be memoized as expected.
However, as the configuration name suggests, this is an experimental feature.
const nextConfig = {
experimental: {
workerThreads: false,
cpus: 1
},
}
Discussion