Skip to content

Commit

Permalink
chore(docs): note cache-control header for preview/draft mode (vercel…
Browse files Browse the repository at this point in the history
…#53825)

You can technically get similar ISR behavior setting the `Cache-Control` in `getServerSideProps()`, but this won't be automatically bypassed when enabling Preview Mode or Draft Mode so this PR adds that to the documentation.

x-ref: [slack discussion](https://vercel.slack.com/archives/C03S8ED1DKM/p1691514209722429)
  • Loading branch information
styfle authored Aug 10, 2023
1 parent 1286e14 commit 2cf5d3a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,9 @@ Then, send a request to `/api/disable-draft` to invoke the API Route. If calling

### Works with `getServerSideProps`

Draft Mode works with `getServerSideProps` as well. It will also be available on the `context` object containing `draftMode`
Draft Mode works with `getServerSideProps`, and is available as a `draftMode` key in the [`context`](/docs/pages/api-reference/functions/get-server-side-props#context-parameter) object.

> **Good to know**: You shouldn't set the `Cache-Control` header when using Draft Mode because it cannot be bypassed. Instead, we recommend using [ISR](/docs/pages/building-your-application/data-fetching/incremental-static-regeneration).
### Works with API Routes

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,8 @@ You can pass an object to `setPreviewData` and have it be available in `getStati

The preview mode works on `getServerSideProps` as well. It will also be available on the `context` object containing `preview` and `previewData`.

> **Good to know**: You shouldn't set the `Cache-Control` header when using Preview Mode because it cannot be bypassed. Instead, we recommend using [ISR](/docs/pages/building-your-application/data-fetching/incremental-static-regeneration).
### Works with API Routes

API Routes will have access to `preview` and `previewData` under the request object. For example:
Expand Down

0 comments on commit 2cf5d3a

Please sign in to comment.