Next.js Discord

Discord Forum

On demand cache re-validation for dynamic segment not working

Unanswered
Bombay posted this in #help-forum
Open in Discord
BombayOP
n our website all paths are static except one path which has dynamic segment, we're generating all the segments when building. We're using manual revalidation with revalidatePath in (api) route handler, like: revalidatePath('/', 'layout'); Unfortunately dynamic segments doesn't updates.

Lets prepare the re-production step. Lets think that we've categories in the api (different backend app, hosted somewhere else), which is cat1, cat2, cat3. This are dynamic data & can change anytime but usually doesn't change often.

We're using this categories as as dynamic segment in Next.js like: /cat/[catName]

Following is the workflow which produces this.

1. Deploy site in vercel.
2. Update first category to cat11
3. Trigger manual (full) revalidation using revalidatePath('/', 'layout');
4. Visit the route which is changed in #2 (/cat/cat11) & 💣🧨🔥 it's showing 404 page
How to re-validate this?

Also available in [StackOverflow](https://stackoverflow.com/questions/77973759/next-js-14-cache-revalidation-not-working-with-dynamic-segment)

8 Replies

Surely it's because you're revalidating / instead of /cat/something
@Bombay
BombayOP
Thank you for the response. According to [this](https://nextjs.org/docs/app/api-reference/functions/revalidatePath#revalidating-all-data) that should work but the behaviousr is different
@Jesse Surely it's because you're revalidating / instead of /cat/something
so you've tried this and it hasn't worked @Bombay
BombayOP
unfortunately not
try switching from layout to page
@Bombay
BombayOP
Tested that doesn't work either,