docs: document cache tagging mechanism (#53806)

This PR document the cache tagging semantics in Next.js, and how to benefit from it during cache revalidation.
This commit is contained in:
Lucas Constantino Silva 2023-08-10 01:18:02 +02:00 committed by GitHub
parent 5fe332186e
commit 0350e00d0d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -94,6 +94,14 @@ Set the cache lifetime of a resource (in seconds).
> - As a convenience, it is not necessary to set the `cache` option if `revalidate` is set to a number since `0` implies `cache: 'no-store'` and a positive value implies `cache: 'force-cache'`.
> - Conflicting options such as `{ revalidate: 0, cache: 'force-cache' }` or `{ revalidate: 10, cache: 'no-store' }` will cause an error.
### `options.next.tags`
```ts
fetch(`https://...`, { next: { tags: ['collection'] } })
```
Set the cache tags of a resource. Data can then be revalidated on-demand using [`revalidateTag`](https://nextjs.org/docs/app/api-reference/functions/revalidateTag).
## Version History
| Version | Changes |