Does NextJS have the ability to cache static pages between builds?
So, for example, when I add a new piece of content without changing the code, a build should just incrementally build that new resources, instead of rebuilding everything. I can use a lastModified field to exclude the previously built files from “getStaticPaths” but that means only the new files get generated and the old ones are lost. Right?
Is there a way to add the new page to an existing build cache?
In general the answer to this question is “use ISR (incremental static regeneration)”. That relies on a nextjs server to be available at runtime to generate the missing pages.
What I’m looking for is a purely build-time solution that takes previously generated and cached pages and just adds new ones to the cache.
2
I think this option is still not available on nextjs. I remember Gatsby did that in version 5 when they introduced the Slice API. Otherwise, if you want a fast rebuild of your app you can use TurboPack. It offers Build Optimization Which eliminates unnecessary bundling of on-demand loaded code before it is needed.
Turbopack:https://turbo.build/pack/docs