Next.js Discord

Discord Forum

Is revalidatePath(`/`) a bad practice?

Answered
Oriental posted this in #help-forum
Open in Discord
OrientalOP
Does someone actually know the downsides of calling revalidatePath('/') to purge the cache? Is it computational expensive? Is it expensive in terms of usage in any Vercel service? What are the main downsides?
Answered by B33fb0n3
in your example, is 100.000 based on my user count
nah, based on the things you fetch on your page. Imagine your are fetching settings (just an example) and you fetch each setting by it's own. Then you might fetch 1.000 settings. And each settings have categories. Imagine each setting is in 100 categories. Like that you fetch 100.000 times and that's not very effective. So you think about hey, I can use cache for that. You cache it and now want to revalidatePath('/'). Will that be very effective, no
View full answer

7 Replies

@Oriental Does someone actually know the downsides of calling `revalidatePath('/')` to purge the cache? Is it computational expensive? Is it expensive in terms of usage in any Vercel service? What are the main downsides?
That really depends on your project. If there are 100.000 caches on the / page and your revalidatePath(/) them, it is a bad pratice, because all 100.000 caches will need to be refetched. Then you might only want to use revalidateTag to revalidate only specific parts of your app. Iirc the revalidate only tells the cache, that it is now outdated
@B33fb0n3 That really depends on your project. If there are 100.000 caches on the / page and your revalidatePath(/) them, it is a bad pratice, because all 100.000 caches will need to be refetched. Then you might only want to use revalidateTag to revalidate only specific parts of your app. Iirc the revalidate only tells the cache, that it is now outdated
OrientalOP
in your example, is 100.000 based on my user count? or the amount of pages the whole user base visits during a period of time? or both? where is this number from? my app is a small app, right now we only have 6 users, but i'm planning in onboarding more people, it will not grow to thousands of users, not even in the far future
in your example, is 100.000 based on my user count
nah, based on the things you fetch on your page. Imagine your are fetching settings (just an example) and you fetch each setting by it's own. Then you might fetch 1.000 settings. And each settings have categories. Imagine each setting is in 100 categories. Like that you fetch 100.000 times and that's not very effective. So you think about hey, I can use cache for that. You cache it and now want to revalidatePath('/'). Will that be very effective, no
Answer
@Orientalsolved?
OrientalOP
yes my friend! that was very helpful
Sure thing