Unverified Commit 8f99ab20 authored by Delba de Oliveira's avatar Delba de Oliveira Committed by GitHub

Docs: Remove legacy tags from unstable_cache and unstable_noStore (#72134)

This was a premature move as the docs made their way into the stable
version. Can't risk these being merged just yet, and they're also not in
canary.
parent d399ed6c
...@@ -51,7 +51,7 @@ This example demonstrates a basic server-side data fetch using the `fetch` API i ...@@ -51,7 +51,7 @@ This example demonstrates a basic server-side data fetch using the `fetch` API i
- [`fetch`](/docs/app/api-reference/functions/fetch) - [`fetch`](/docs/app/api-reference/functions/fetch)
- React [`cache`](https://react.dev/reference/react/cache) - React [`cache`](https://react.dev/reference/react/cache)
- Next.js [`unstable_cache`](/docs/app/api-reference/legacy-apis/unstable_cache) - Next.js [`unstable_cache`](/docs/app/api-reference/functions/unstable_cache)
## Examples ## Examples
......
...@@ -104,7 +104,7 @@ Dynamic APIs rely on information that can only be known at request time (and not ...@@ -104,7 +104,7 @@ Dynamic APIs rely on information that can only be known at request time (and not
- [`connection`](/docs/app/api-reference/functions/connection) - [`connection`](/docs/app/api-reference/functions/connection)
- [`draftMode`](/docs/app/api-reference/functions/draft-mode) - [`draftMode`](/docs/app/api-reference/functions/draft-mode)
- [`searchParams` prop](/docs/app/api-reference/file-conventions/page#searchparams-optional) - [`searchParams` prop](/docs/app/api-reference/file-conventions/page#searchparams-optional)
- [`unstable_noStore`](/docs/app/api-reference/legacy-apis/unstable_noStore) - [`unstable_noStore`](/docs/app/api-reference/functions/unstable_noStore)
- [`unstable_after`](/docs/app/api-reference/functions/unstable_after) - [`unstable_after`](/docs/app/api-reference/functions/unstable_after)
### Streaming ### Streaming
......
...@@ -389,7 +389,7 @@ The following table provides an overview of how different Next.js APIs affect ca ...@@ -389,7 +389,7 @@ The following table provides an overview of how different Next.js APIs affect ca
| [`headers`, `searchParams`](#dynamic-apis) | | Opt out | | | | [`headers`, `searchParams`](#dynamic-apis) | | Opt out | | |
| [`generateStaticParams`](#generatestaticparams) | | Cache | | | | [`generateStaticParams`](#generatestaticparams) | | Cache | | |
| [`React.cache`](#react-cache-function) | | | | Cache | | [`React.cache`](#react-cache-function) | | | | Cache |
| [`unstable_cache`](/docs/app/api-reference/legacy-apis/unstable_cache) | | | Cache | | | [`unstable_cache`](/docs/app/api-reference/functions/unstable_cache) | | | Cache | |
### `<Link>` ### `<Link>`
...@@ -451,7 +451,7 @@ See the [`fetch` API reference](/docs/app/api-reference/functions/fetch) for mor ...@@ -451,7 +451,7 @@ See the [`fetch` API reference](/docs/app/api-reference/functions/fetch) for mor
Next.js has a cache tagging system for fine-grained data caching and revalidation. Next.js has a cache tagging system for fine-grained data caching and revalidation.
1. When using `fetch` or [`unstable_cache`](/docs/app/api-reference/legacy-apis/unstable_cache), you have the option to tag cache entries with one or more tags. 1. When using `fetch` or [`unstable_cache`](/docs/app/api-reference/functions/unstable_cache), you have the option to tag cache entries with one or more tags.
2. Then, you can call `revalidateTag` to purge the cache entries associated with that tag. 2. Then, you can call `revalidateTag` to purge the cache entries associated with that tag.
For example, you can set a tag when fetching data: For example, you can set a tag when fetching data:
......
...@@ -64,7 +64,7 @@ While building your application, we recommend using the following features to en ...@@ -64,7 +64,7 @@ While building your application, we recommend using the following features to en
- **[Route Handlers](/docs/app/building-your-application/routing/route-handlers):** Use Route Handlers to access your backend resources from Client Components. But do not call Route Handlers from Server Components to avoid an additional server request. - **[Route Handlers](/docs/app/building-your-application/routing/route-handlers):** Use Route Handlers to access your backend resources from Client Components. But do not call Route Handlers from Server Components to avoid an additional server request.
- **[Streaming](/docs/app/building-your-application/routing/loading-ui-and-streaming):** Use Loading UI and React Suspense to progressively send UI from the server to the client, and prevent the whole route from blocking while data is being fetched. - **[Streaming](/docs/app/building-your-application/routing/loading-ui-and-streaming):** Use Loading UI and React Suspense to progressively send UI from the server to the client, and prevent the whole route from blocking while data is being fetched.
- **[Parallel Data Fetching](/docs/app/building-your-application/data-fetching/fetching#parallel-and-sequential-data-fetching):** Reduce network waterfalls by fetching data in parallel, where appropriate. Also, consider [preloading data](/docs/app/building-your-application/data-fetching/fetching#preloading-data) where appropriate. - **[Parallel Data Fetching](/docs/app/building-your-application/data-fetching/fetching#parallel-and-sequential-data-fetching):** Reduce network waterfalls by fetching data in parallel, where appropriate. Also, consider [preloading data](/docs/app/building-your-application/data-fetching/fetching#preloading-data) where appropriate.
- **[Data Caching](/docs/app/building-your-application/caching#data-cache):** Verify whether your data requests are being cached or not, and opt into caching, where appropriate. Ensure requests that don't use `fetch` are [cached](/docs/app/api-reference/legacy-apis/unstable_cache). - **[Data Caching](/docs/app/building-your-application/caching#data-cache):** Verify whether your data requests are being cached or not, and opt into caching, where appropriate. Ensure requests that don't use `fetch` are [cached](/docs/app/api-reference/functions/unstable_cache).
- **[Static Images](/docs/app/building-your-application/optimizing/static-assets):** Use the `public` directory to automatically cache your application's static assets, e.g. images. - **[Static Images](/docs/app/building-your-application/optimizing/static-assets):** Use the `public` directory to automatically cache your application's static assets, e.g. images.
</AppOnly> </AppOnly>
......
...@@ -65,7 +65,7 @@ export async function getData() { ...@@ -65,7 +65,7 @@ export async function getData() {
- Functions that use the `use cache` directive must not have any side-effects, such as modifying state, directly manipulating the DOM, or setting timers to execute code at intervals. - Functions that use the `use cache` directive must not have any side-effects, such as modifying state, directly manipulating the DOM, or setting timers to execute code at intervals.
- If used alongside [Partial Prerendering](/docs/app/building-your-application/rendering/partial-prerendering), segments that have `use cache` will be prerendered as part of the static HTML shell. - If used alongside [Partial Prerendering](/docs/app/building-your-application/rendering/partial-prerendering), segments that have `use cache` will be prerendered as part of the static HTML shell.
- The `use cache` directive will be available separately from the [`dynamicIO`](/docs/app/api-reference/next-config-js/dynamicIO) flag in the future. - The `use cache` directive will be available separately from the [`dynamicIO`](/docs/app/api-reference/next-config-js/dynamicIO) flag in the future.
- Unlike [`unstable_cache`](/docs/app/api-reference/legacy-apis/unstable_cache) which only supports JSON data, `use cache` can cache any serializable data React can render, including the render output of components. - Unlike [`unstable_cache`](/docs/app/api-reference/functions/unstable_cache) which only supports JSON data, `use cache` can cache any serializable data React can render, including the render output of components.
## Examples ## Examples
......
...@@ -47,7 +47,7 @@ function connection(): Promise<void> ...@@ -47,7 +47,7 @@ function connection(): Promise<void>
## Good to know ## Good to know
- `connection` replaces [`unstable_noStore`](/docs/app/api-reference/legacy-apis/unstable_noStore) to better align with the future of Next.js. - `connection` replaces [`unstable_noStore`](/docs/app/api-reference/functions/unstable_noStore) to better align with the future of Next.js.
- The function is only necessary when dynamic rendering is required and common Dynamic APIs are not used. - The function is only necessary when dynamic rendering is required and common Dynamic APIs are not used.
### Version History ### Version History
......
--- ---
title: unstable_cache title: unstable_cache
description: API Reference for the unstable_cache function. description: API Reference for the unstable_cache function.
version: legacy
--- ---
In version 15, we recommend using the [`use cache`](/docs/app/api-reference/directives/use-cache) directive instead. > This API will be deprecated in future versions. If you're using Next.js 15 canary, we recommend using [`connection`](/docs/app/api-reference/functions/connection) instead of `unstable_noStore`.
`unstable_cache` allows you to cache the results of expensive operations, like database queries, and reuse them across multiple requests. `unstable_cache` allows you to cache the results of expensive operations, like database queries, and reuse them across multiple requests.
......
--- ---
title: unstable_noStore title: unstable_noStore
description: API Reference for the unstable_noStore function. description: API Reference for the unstable_noStore function.
version: legacy
--- ---
In version 15, we recommend using [`connection`](/docs/app/api-reference/functions/connection) instead of `unstable_noStore`. > This API will be deprecated in future versions. If you're using Next.js 15 canary, we recommend using [`connection`](/docs/app/api-reference/functions/connection) instead of `unstable_noStore`.
`unstable_noStore` can be used to declaratively opt out of static rendering and indicate a particular component should not be cached. `unstable_noStore` can be used to declaratively opt out of static rendering and indicate a particular component should not be cached.
...@@ -23,7 +22,7 @@ export default async function ServerComponent() { ...@@ -23,7 +22,7 @@ export default async function ServerComponent() {
> - `unstable_noStore` is equivalent to `cache: 'no-store'` on a `fetch` > - `unstable_noStore` is equivalent to `cache: 'no-store'` on a `fetch`
> - `unstable_noStore` is preferred over `export const dynamic = 'force-dynamic'` as it is more granular and can be used on a per-component basis > - `unstable_noStore` is preferred over `export const dynamic = 'force-dynamic'` as it is more granular and can be used on a per-component basis
- Using `unstable_noStore` inside [`unstable_cache`](/docs/app/api-reference/legacy-apis/unstable_cache) will not opt out of static generation. Instead, it will defer to the cache configuration to determine whether to cache the result or not. - Using `unstable_noStore` inside [`unstable_cache`](/docs/app/api-reference/functions/unstable_cache) will not opt out of static generation. Instead, it will defer to the cache configuration to determine whether to cache the result or not.
## Usage ## Usage
......
---
title: Legacy APIs
description: API Reference for Next.js Legacy APIs.
---
The following APIs are considered legacy and will be removed in a future version of Next.js:
...@@ -39,5 +39,5 @@ export async function GET() { ...@@ -39,5 +39,5 @@ export async function GET() {
- [`headers()` function](https://nextjs.org/docs/app/api-reference/functions/headers) - [`headers()` function](https://nextjs.org/docs/app/api-reference/functions/headers)
- [`cookies()` function](https://nextjs.org/docs/app/api-reference/functions/cookies) - [`cookies()` function](https://nextjs.org/docs/app/api-reference/functions/cookies)
- [`draftMode()` function](https://nextjs.org/docs/app/api-reference/functions/draft-mode) - [`draftMode()` function](https://nextjs.org/docs/app/api-reference/functions/draft-mode)
- [`unstable_noStore()` function](https://nextjs.org/docs/app/api-reference/legacy-apis/unstable_noStore) - [`unstable_noStore()` function](https://nextjs.org/docs/app/api-reference/functions/unstable_nostore)
- [`unstable_cache()` function](https://nextjs.org/docs/app/api-reference/legacy-apis/unstable_cache) - [`unstable_cache()` function](https://nextjs.org/docs/app/api-reference/functions/unstable_cache)
...@@ -10,7 +10,7 @@ When Partial Prerendering (PPR) is enabled, using APIs that opt into Dynamic Ren ...@@ -10,7 +10,7 @@ When Partial Prerendering (PPR) is enabled, using APIs that opt into Dynamic Ren
- Ensure that you are not wrapping Next.js APIs that opt into dynamic rendering in a `try/catch` block. - Ensure that you are not wrapping Next.js APIs that opt into dynamic rendering in a `try/catch` block.
- If you do wrap these APIs in a try/catch, make sure you re-throw the original error so it can be caught by Next.js. - If you do wrap these APIs in a try/catch, make sure you re-throw the original error so it can be caught by Next.js.
- Alternatively, insert [`unstable_noStore()`](/docs/app/api-reference/legacy-apis/unstable_noStore) before the try/catch. - Alternatively, insert [`unstable_noStore()`](/docs/app/api-reference/functions/unstable_noStore) before the try/catch.
```js ```js
import { unstable_noStore } from 'next/cache' import { unstable_noStore } from 'next/cache'
......
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