Unverified Commit f63088d2 authored by Joseph's avatar Joseph Committed by GitHub

docs: Middleware fetching is not cached (#80378)

Closes:
https://linear.app/vercel/issue/DOC-4751/docs-missing-middleware-caching-information-also-ts-types-issue
Fixes: https://github.com/vercel/next.js/issues/77900

Note that the TypeScript (should the TS plugin detect fetch
`options.next` used in middleware and error out?) issue is still
pending. It will be eventually handled.
parent a0d671c1
......@@ -20,6 +20,8 @@ Middleware is _not_ a good fit for:
- Slow data fetching
- Session management
Using fetch with `options.cache`, `options.next.revalidate`, or `options.next.tags`, has no effect in Middleware.
## Convention
Use the file `middleware.ts` (or `.js`) in the root of your project to define Middleware. For example, at the same level as `pages` or `app`, or inside `src` if applicable.
......
......@@ -31,6 +31,8 @@ By default, Next.js will cache as much as possible to improve performance and re
Caching behavior changes depending on whether the route is statically or dynamically rendered, data is cached or uncached, and whether a request is part of an initial visit or a subsequent navigation. Depending on your use case, you can configure the caching behavior for individual routes and data requests.
Fetch caching is **not** supported in `middleware`. Any fetches done inside of your `middleware` will be uncached.
## Request Memoization
Next.js extends the [`fetch` API](#fetch) to automatically **memoize** requests that have the same URL and options. This means you can call a fetch function for the same data in multiple places in a React component tree while only executing it once.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment