How to disable vercel caching thing?
Answered
Mugger Crocodile posted this in #help-forum
Mugger CrocodileOP
I am getting the same responses even if the db items change, I do not get the same thing within the localhost app, I know its something about vercel caching, what can I do to stop it, I tried this
import {connectToDB} from "@utils/database";
import Prompt from "@models/prompt";
export const GET = async(req, res) => {
try {
await connectToDB();
const prompts = await Prompt.find({}).populate('creator');
return new Response(JSON.stringify(prompts), {status: 200, headers: {
'Cache-Control': 'no-store'
}})
} catch (error) {
return new Response("Failed to fetch all prompts", {status:500})
}
} but it does not workAnswered by Ray
export const dynamic = 'force-dynamic'you could use route segment config to set it dynamic
7 Replies
export const dynamic = 'force-dynamic'you could use route segment config to set it dynamic
Answer
Mugger CrocodileOP
where should I use this?
in the route.js?
@Ray GET endpoint is static by default
Mugger CrocodileOP
export const forceRevalidate = (request) => {
const path = request.nextUrl.searchParams.get("path") || "/";
revalidatePath(path);
}; I tried to use this, and it works, but it should disable the entire cachingMugger CrocodileOP
tyvm