Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does next js implement a maximum cache size with an invalidation algorithm such as LRU?

I have a next js site that uses getServerSideProps. I would like to use getStaticProps and incremental static regeneration (ISR) instead for the performance advantages. My current memory use is about 125MB. Crawling all of the pages when using getStaticProps results in using around 2G of memory. I would like to fit the pages into 500Mb but I don't see anyway to set an upper limit on the cache used by getStaticProps.

like image 616
Mark Gibbons Avatar asked May 09 '26 03:05

Mark Gibbons


1 Answers

You can set and tweak with the isrMemoryCacheSize parameter in next.config.js and define how much memory you want to use for the inMemory cache.

Just keep in check that this is a rather recent feature that's not very well documented. The only hint you can tweak this setting is located here: https://nextjs.org/docs/basic-features/data-fetching/incremental-static-regeneration#self-hosting-isr

like image 107
Gus Fune Avatar answered May 15 '26 05:05

Gus Fune



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!