Hi @anshumanb. I’ll share some snippets of code at a high level, but unfortunately I cannot share all the code or the exact code.
What I can say is that the app uses nextjs 14.2.3 (app uses app router), Drizzle ORM 0.38.4 to perform database queries against a Supabase Postgres database. The db calls are cached using unstable_cache with a tag specified and a revalidate time of one day. My database queries follow this pattern:
export const invokeCachedDbQuery = unstable_cache(
async (param) => {
param
);
return invokeDbQuery(
param
);
},
[],
{ tags: "mytag", revalidate: 86400}
);
I also have a Vercel cron job that invalidates this cache every day by invoking a route whose business logic invalidates the cache using the tag:
export async function GET(request: NextRequest) {
revalidateTag("myTag");
revalidatePath('/', 'layout');
const response = NextResponse.json({
success: true,
message: 'Caches invalidated',
});
response.headers.set('Cache-Control', 'no-store, no-cache, must-revalidate, proxy-revalidate');
response.headers.set('X-Robots-Tag', 'noindex, nofollow');
return response;
}
Many of my pages (page.tsx) are also invalidated once per day:
export const revalidate = 86400;
Strangely, this API call seems to work sometimes to invalidate the database cache, but there are times when it seemingly doesn’t. That’s when I resort to purging the data cache from the Vercel console. This method of purging the cache via the Vercel console always seems to work though, and that’s why I was hoping Vercel would make a RESTful API endpoint to allow for this so I don’t have to manually purge the cache everyday.
I wish I could provide more details, but this is the best I can do. Not sure if you can provide any help with these limited details, but I would definitely appreciate any advice or info. Thanks!