Next.js Discord

Discord Forum

On-demand ISR, how to correctly update bulk of urls?

Answered
Vadym posted this in #help-forum
Open in Discord
Hello, folks!
I have a dynamic page with semantic URL params like my-domain. com/[city]/[service].

In these pages, I output lists of products.

When some of the products were changed, not build-in API triggered api/revalidate.page.ts inside the pages folder to revalidate this array of URLs.

It works, but I'm afraid that I will catch some performance problems if my outside API asks nextjs to revalidate more than 100+ URLs at once.

It would be amazing to receive any suggestions on how to correctly deal with an array of URLs to revalidate pages.
Answered by Arinji
but yea so i fetch the api route which gives me the author data, and then i give it a static tag, so instead of something page specific, its just general "authors" and then from my cms i just make a request to revalidate any tags with the tag name of author
View full answer

17 Replies

any suggestion?
@Vadym it wont cause any issues
how nextjs revalidation works is that it wont instantly fetch new data
it tells nextjs "Hey, your data is stale.. on the next navigation get new stuff"
so it wont like instantly make your server max out resources trying to fetch a bunch of new data
only when a user opens the link, it will fetch new data
hmm, thanks for suggestion!
can you provide some minimal example how you are working with this bunch of urls to revalidate?
well i currently use this for like my external cms to revalidate my wiki urls
so imagine i have an authors section, now thats gonna be similar per page, but needs to update if i update the author
(i cant show code, but can explain what i do)
just one more question, in your cms api, do you send array of urls to nexjs api/revalidate.page.ts or you are sending new requests in a cycle?
but yea so i fetch the api route which gives me the author data, and then i give it a static tag, so instead of something page specific, its just general "authors" and then from my cms i just make a request to revalidate any tags with the tag name of author
Answer
but yes if i want to generally mass update, i will just map through all the links and send requests to revalidate them
its fine, wont cause issues
amazing, thanks!
np :D