Repository navigation
Loss of functionality: Ability to set SSR cache-control based on API response #49122
Unanswered
steve-taylor
asked this question in
App Router
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
In the old router,
getServerSidePropscan be used to setCache-Controlheaders based on an API response. It's mentioned in the docs here.It would look something like this:
The important thing here is that we don't know what
s-maxagewill be until we get a response from the API.In the new app router, we can't do this. We need to set
revalidateahead of time:And then that
revalidatevalue is used as the TTL of the SSR page.Unless there is something I'm missing here, this is functionality that has gone missing in the new app router and the
revalidatething onfetchneeds to be thought through properly. Alternatively, there needs to be a dynamic alternative toexport const revalidate = <whatever>;, e.g.export const async getRevalidate() { /* ... */ }.All reactions