跳到内容
配置next.config.jsonDemandEntries

onDemandEntries

Next.js 提供了一些选项,让你可以控制服务器如何在开发环境中处理或保留已构建页面的内存。

要更改默认设置,请打开 next.config.js 并添加 onDemandEntries 配置

next.config.js
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,
  },
}