跳到內容

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,
  },
}