apollographql / apollographql/apollo-client-integrations
Prevent a new cache for each SSR request
- Dominant language
- TypeScript
- Stars
- 556
- Forks
- 53
- PR merge metrics
- No merged PRs in 30d
Description
Hi !
According to this quote:
> @apollo/experimental-nextjs-app-support makes sure that we only instance the Apollo Client once per request, since Apollo Client’s cache is designed with a single user in mind, we recommend that your Next.js server instantiates a new cache for each SSR request, rather than reusing the same long-lived instance for multiple users’ data.
[Read more here](https://www.apollographql.com/blog/how-to-use-apollo-client-with-next-js-13?ref=dailydev&utm_source=chatgpt.com#an-example-of-data-fetching-inside-server-components)
It seems that Apollo Client creates a next cache by SSR request, probably according to the header.
The problem is that for the same user, a request can be cached several times if the headers contain data modified during the same session.
Have I understood the current behavior correctly and is it still relevant?
If so, is it possible to customize this operation, for example to create a cache per request only for 1 same user ID to prevent a huge amount of data being cached for nothing ?
Versions:
`"next": "15.3.0"`
`"@apollo/experimental-nextjs-app-support": "^0.11.2"`
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by reviewing @apollo/experimental-nextjs-app-support with Next.js 15.3.0 and the linked Apollo guidance to establish how SSR requests and headers affect cache creation. Confirm the current behavior, then determine whether a per-user cache customization is a supported and well-scoped change.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- graphql, next.js, typescript
- Domain
- backend, performance
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100