コンテンツへスキップ
設定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,
  },
}