-
Notifications
You must be signed in to change notification settings - Fork 30.3k
Description
What is the documentation issue?
An update to the NextJS middleware and caching documentation that would be beneficial is a clear reference to limits of the data cache and cache revalidation, and specifically how it differs in middleware versus elsewhere. The NextJS middleware (apparently) has no access to the data cache, unlike the rest of the app, and thus tags and cache revalidation do not work, but the docs make no explicit mention of this. Despite this, our app's dev server ran and the app built and served on production Vercel deployment without complaint when fetch tags were used. This also indicates a limitation in the relevant Typescript types and app build checking.
Is there any context that might help us understand?
Some other context:
- Our app is served with Vercel, and the client in question that we attempted to cache is the next-sanity client
I'm aware that the beginning of the docs say it runs before cached content and routes are matched. However, that is the only reference related to this, and this either doesn't address the lack of connection to data cache or is a fairly vague one. Also, the app runs and builds without complaint when {next: {tags: ['sometag'] } } are added to fetch requests in the middleware, so at the least, this should fixed to complain about that in build and in Typescript types - I'm using NextJS 14, and haven't tested this on 15.
- In the 14 version of the Caching docs, it makes a mention of the data cache middleware disconnect (screenshot below), but any mention of middleware is gone in the 15 version
Does the docs page already exist? Please link to it.
Caching: https://nextjs.org/docs/app/building-your-application/caching
Middleware: https://nextjs.org/docs/app/building-your-application/routing/middleware