コンテンツへスキップ

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