Skip to content

onDemandEntries

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

¥Next.js exposes some options that give you some control over how the server will dispose or keep in memory built pages in development.

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

¥To change the defaults, open next.config.js and add the onDemandEntries 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,
  },
}

Next.js v15.2 中文网 - 粤ICP备13048890号