跳到內容
配置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,
  },
}