onDemandEntries
配置 Next.js 在开发环境中如何释放和保留内存中创建的页面。
Next.js 提供了一些选项,让你可以在开发环境中对服务器如何释放或保留内存中已构建的页面进行一定程度的控制。
要更改默认值,请打开 next.config.js 并添加 onDemandEntries 配置:
next.config.jsjs
module.exports = {
onDemandEntries: {
// period (in ms) where the server will keep pages in the buffer
maxInactiveAge: 25 * 1000,
// number of pages that should be kept simultaneously without being disposed
pagesBufferLength: 2,
},
}