I have a Next.js 13 project hosted on Netlify.
Initially, the project only had static pages & it was working nicely.
Lately, I’ve added several SSR pages that makes use of the fetch function.
And I’m also using the next: { tags: ... } & revalidateTag features of next.js.
Everything was working nicely locally, but when I deployed to Netlify, the caching doesn’t seem to be working as expected. Mainly, when I invalidate the caching, it’s not being invalidated.
When I checked the Netlify logs, I saw this error being thrown whenever the revalidate api is being called:
Failed to update tags manifest. [Error: ENOENT: no such file or directory, mkdir '/var/task/.next/cache'] {
errno: -2,
code: 'ENOENT'
syscall: 'mkdir',
path: '/var/task/.next/cache'
}
I’m not exactly sure what is the reason of the issue here…
I tried clearing the deploy cache & re-deploying, but it wasn’t related.
If you need me to provide any extra info, let me know.
Well that might prove to be a problem in my project’s case….
The revalidation on timeout will work without issues you say??
Like this request: fetch('https://...', { next: { revalidate: 3600 } }) ??
One other thing.
When I was looking more into this issue 2 days ago, I think I came across this page: Next.js on Netlify | Netlify Docs
& it had a point saying that “on demand caching invalidation” isn’t fully supported & it suggested using something called “on-demand builders” I think.
Is this something that can be used to solve this kind of problem that I’m facing or is it a different thing??
a revalidate timeout in an ISR function - with something like the code you share - does work and is what I was indeed suggesting and what the docs are trying to suggest as well.
What you maybe didn’t know is that we implemented ISR using on-demand builder functions automatically, when there is a revalidate directive
Is there btw any online code/example-repo showing how on-demand builders can be used in a next.js project to get a result similar to what the revalidateTag is supposed to achieve?
I tried searching for one online, but haven’t found any.
That’s currently in a private beta and I won’t recommend for production usage (which is why the docs aren’t public yet). The API is very likely to keep changing, and we won’t be able to provide any active support till it’s GA. If you’re still interested, let us know and we can try setting your site up for that.
@hrishikesh Any news on revalidateTag support? When using NextJS with a headless CMS, this feature is quite crucial as you might guess. We cant live without that.