Next.js Discord

Discord Forum

Debugging cache in Next.js?

Unanswered
American black bear posted this in #help-forum
Open in Discord
American black bearOP
I am having a problem where I don't know under which path/tag my data is cached. With redis you would just print out the key/values and see what you need to revalidate. Is something similar possible with Next.js?

Calling revalidatePath("/") refreshes the cache as intended but when I try to specify a specific route e.g. /tenant-domain/localhost:3000/en/about it does not work.

I have tried digging in the .next folder to find if cache is stored there but I've only found the cached results of native fetch and no signs of "use cache" and ISR cached content/functions.

Any ideas are appreciated 🙏

I am using next@16.0.4 and use cache directive for caching my functions as well as on-demand ISR.

2 Replies

Hey you might want to check out this tool https://next-cache-tools.com/docs/getting-started
American black bearOP
This library looks awesome. I have built something similar myself, but it has a bit more boilerplate. My main problem here is the ISR cache since I have a middleware (now proxy.ts) rewrite which inserts a tenant as a param in url:

/tenant-domain/[tenantDomain]/[locale]/[[...slug]] in browser rewrites to -> /[locale]/[[...slug]]

but I am unable to invalidate the ISR cache for said path like this:

revalidatePath("/tenant-domain/example.com/en/about") only thing that works is revalidatePath("/")