跳至內容
API 參考next.config.js 選項隨需載入項目 (onDemandEntries)

隨需載入項目 (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,
  },
}