| `stale` | `number` | Duration the client should cache a value without checking the server. | Optional |
| `stale` | `number` | Duration the client should cache a value without checking the server. | Optional |
| `revalidate` | `number` | Frequency at which the cache should refresh on the server; stale values may be served while revalidating. | Optional |
| `revalidate` | `number` | Frequency at which the cache should refresh on the server; stale values may be served while revalidating. | Optional |
| `expire` | `number` | Maximum duration for which a value can remain stale before switching to dynamic fetching; must be longer than `revalidate`. | Optional - Must be longer than `revalidate` |
| `expire` | `number` | Maximum duration for which a value can remain stale before switching to dynamic fetching; must be longer than `revalidate`. | Optional - Must be longer than `revalidate` |
...
@@ -128,7 +128,7 @@ The "stale" property differs from the [`staleTimes`](/docs/app/api-reference/nex
...
@@ -128,7 +128,7 @@ The "stale" property differs from the [`staleTimes`](/docs/app/api-reference/nex
Next.js provides a set of named cache profiles modeled on various timescales. If you don'tspecifyacacheprofileinthe`cacheLife`functionalongsidethe`use cache`directive,Next.jswillautomaticallyapplythe“default”cacheprofile.
Next.js provides a set of named cache profiles modeled on various timescales. If you don'tspecifyacacheprofileinthe`cacheLife`functionalongsidethe`use cache`directive,Next.jswillautomaticallyapplythe“default”cacheprofile.
And in your `page.tsx` file you can add the `usecache` directive to the top of the file, and define a cache profile:
And in your `page.tsx` file you can add the `usecache` directive to the top of the file, and define a cache profile:
```tsxfilename="app/page.tsx"
```tsxfilename="app/page.tsx"
...
@@ -346,19 +347,19 @@ You can use `use cache` at the component level to cache any fetches or computati
...
@@ -346,19 +347,19 @@ You can use `use cache` at the component level to cache any fetches or computati
The props are serialized and form part of the cache key. If you use the same component in multiple places in your application, the cache entry will be reused as long as the serialized props produce the same value in each instance.
The props are serialized and form part of the cache key. If you use the same component in multiple places in your application, the cache entry will be reused as long as the serialized props produce the same value in each instance.
Since you can add `usecache` to any asynchronous function you aren't limited to caching components or routes only. You might want to cache a network request or database query or compute something that is very slow. By adding `usecache` to a function containing this type of work it becomes cacheable, and when reused, will share the same cache entry.
Since you can add `usecache` to any asynchronous function you aren't limited to caching components or routes only. You might want to cache a network request or database query or compute something that is very slow. By adding `usecache` to a function containing this type of work it becomes cacheable, and when reused, will share the same cache entry.