On-demand revalidation app directory, is this expected behavior?
Unanswered
Pixiebob posted this in #help-forum
PixiebobOP
When running my on-demand revalidate route in /api/revalidate:
And then going to route: 'http://localhost:3000/' the route has to refetch the page data again as if the cache was purged but not revalidated. I thought it was suppose to refetch and cache.
This is using npm run build && npm run start (production build).
Any ideas? Or am i misunderstanding this?
import { revalidatePath } from "next/cache";
import { NextRequest, NextResponse } from "next/server";
export const dynamic = 'force-dynamic';
export async function GET() {
try {
revalidatePath('/');
return NextResponse.json(
{ message: 'Revalidation successful' },
{ status: 200 }
);
} catch (error) {
console.log(error)
return NextResponse.json(
{ error: 'Error revalidating'},
{ status: 500 }
);
}
}And then going to route: 'http://localhost:3000/' the route has to refetch the page data again as if the cache was purged but not revalidated. I thought it was suppose to refetch and cache.
This is using npm run build && npm run start (production build).
Any ideas? Or am i misunderstanding this?
1 Reply
PixiebobOP
Adding fetch(
http://localhost:3000${path}); fixed it. I missed that revalidatePath only clears the cache.