コンテンツにスキップ

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