1

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
  • This question is similar to: How to add new pages without rebuilding an app with +150k static pages?. If you believe it’s different, please edit the question, make it clear how it’s different and/or how the answers on that question are not helpful for your problem. Commented Sep 12, 2024 at 22:39
  • Thanks. I've updated the question to clarify what I'm looking for, and how it's different from that question Commented Sep 13, 2024 at 2:09

1 Answer 1

0

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.