generateStaticParams and how to rebuild only changed pages #69013
Unanswered
mlinden87
asked this question in
App Router
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Got a blog page, and in the dynamic [postSlug] route, I use generateStaticParams to fetch a list of all published posts from the database, and then SSG them. I used tags in the fetch call and a revalidation endpoint in my CMS to invalidate the cache when a post is edited or a new post is added.
Problem is, whenever I do that, all pages get rebuilt, not just the new/edited one, resulting in a lot of unnecessary egress.
I mean, the behaviour does make sense since generateStaticParams just fetches a list of all posts to then statically render, and has no way of knowing which are new, and which are unchanged. Even if it was possible to compare it to cached pages, it would need to build a page to compare to the cached version first, and at that point it's already built anyway.
Is there a way to optimize this scenario? Like in generateStaticParams fetch the list of all posts, but pass a second argument/list to say "only rebuild these pages, use the cache for the others".
Beta Was this translation helpful? Give feedback.
All reactions