Unverified Commit 5feb400a authored by Francis Gulotta's avatar Francis Gulotta Committed by GitHub

docs: clarify when you use getServerSideProps (#35922)

Removed the misleading TTFB information. It was easy to read that incorrectly and while getStaticProps does have a better TTFB that's not why you might need to avoid getServerSideProps, I gave better examples. 

I also wanted to answer "well how do I cache `getServerSideProps`?" and now there's a link.

## Documentation / Examples

- [x] Make sure the linting passes by running `yarn lint`
parent 630bf80a
......@@ -33,9 +33,9 @@ The [`getServerSideProps` API reference](/docs/api-reference/data-fetching/get-s
## When should I use getServerSideProps
You should use `getServerSideProps` only if you need to pre-render a page whose data must be fetched at request time. [Time to First Byte (TTFB)](https://web.dev/ttfb/) will be higher than [`getStaticProps`](/docs/basic-features/data-fetching/get-static-props.md) because the server must compute the result on every request, and the result can only be cached by a CDN using `cache-control` headers (which could require extra configuration).
You should use `getServerSideProps` only if you need to render a page whose data must be fetched at request time. This could be due to the nature of the data or properties of the request (such as `authorization` headers or geo location). Pages using `getServerSideProps` will be server side rendered at request time and only be cached if [cache-control headers are configured](/docs/going-to-production#caching).
If you do not need to pre-render the data, then you should consider fetching data on the [client side](#fetching-data-on-the-client-side).
If you do not need to render the data during the request, then you should consider fetching data on the [client side](#fetching-data-on-the-client-side) or [`getStaticProps`](/docs/basic-features/data-fetching/get-static-props).
### getServerSideProps or API Routes
......
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