Strategy for many pages infrequently but collaboratively updated?
Answered
Yellow-horned horntail posted this in #help-forum
Yellow-horned horntailOP
Hello everyone. Next.js newbie here. I'm designing a website that I expect to end up with hundreds of thousands of pages, each sourced by data from a database. People will collaboratively create and maintain the pages. I expect there to be a flurry of collaborative activity to initially create the pages (by creating the underlying data), and then only infrequent collaborative activity (every few months) maintaining the pages. It's okay to have a revalidation period for public access to the pages, as with logged in users who do not have edit access to a page, but the folks who are improving any given page are working together and will need each change as it's made.
What's an appropriate page generation and caching strategy? Can I just call
What's an appropriate page generation and caching strategy? Can I just call
res.revalidate every time a page changes? If so, how would I avoid having getStaticProps pull this enormous amount of data from the database at build time? Would I just build configured for an empty database?Answered by Rafael Almeida
I recommend using an empty
paths array and fallback: 'blocking'. with this settings the initial access to the page will behave like ssr then the next access will be instant since the page will be cached4 Replies
Yellow-horned horntailOP
After more research, I'm guessing that I can do this with:
Initial page props will be "empty" (undefined?), so I can provide a skeleton version of the page sans data.
export function getStaticPaths() {
return {
paths: [],
fallback: true // or 'blocking'
};
}Initial page props will be "empty" (undefined?), so I can provide a skeleton version of the page sans data.
@Yellow-horned horntail After more research, I'm guessing that I can do this with:
export function getStaticPaths() {
return {
paths: [],
fallback: true // or 'blocking'
};
}
Initial page props will be "empty" (undefined?), so I can provide a skeleton version of the page sans data.
I recommend using an empty
paths array and fallback: 'blocking'. with this settings the initial access to the page will behave like ssr then the next access will be instant since the page will be cachedAnswer
and yeah you can call
revalidate in the pages after they have been edited, so people can see the edits in real timeYellow-horned horntailOP
Thank you so much!