Static page generation timeout before each page
Unanswered
Siamese Crocodile posted this in #help-forum
Siamese CrocodileOP
Hi. I've static pages with different locales (1500pages * 2locales) - when building an app my backend (nestjs) receives a lot of requests in a short period of time. How can I configure nextjs to wait some time before next static page?
10 Replies
Siamese CrocodileOP
e.g. we generate those static pages
and each page runs
getBySlug
and after 700 pages backend timeouts bc of too many requests
Siamese CrocodileOP
So I need to set up a delay before each page generation but I cant find an option to do so
@Siamese Crocodile So I need to set up a delay before each page generation but I cant find an option to do so
West African Lion
If it goes one by one, maybe make a delay on your backend to respond after for example 3 seconds
Siamese CrocodileOP
Nah thats not an option
btw I am not sure if next does it one by one
I've added 3s timeout after fetching a single page but logs didnt look like each page was generated for 3 seconds
i think the page generation is parallelised. which makes it quite hard for things like this.
since you can access the backend code, i think you should do this:
* set up a rate limiter in the backend, so it doesn't crash.
* in the nextjs build, just loop if the request fails due to the rate limiter. maybe stop looping after the 10th iteration.
since you can access the backend code, i think you should do this:
* set up a rate limiter in the backend, so it doesn't crash.
* in the nextjs build, just loop if the request fails due to the rate limiter. maybe stop looping after the 10th iteration.