When use the Apollo Client server side rendering, How to share the cache in cluster server (k8s)?

Our project use Astro + Apollo + graphQL to render the client page, use the InMamoryCache to cache data, and we have a lot of child render server in cluster servers, but the cache is stored in mamory, so each child render server has a cache, now we need re-fetch each render server to refresh the data, that is a big problem, so my question is how to share the cache in all render servers? if can share the cache in all render servers, we just need re-fetch once, all data will be changed…

I seen the apollo3-cache-persist, it will save the cache to locale files, then I share the cache files to each child render servers in cluster server, look like is feasible.

Faild, apollo3-cache-persist will persist data to local file, but cannot to update the local file cache

Hi @dande.sun :wave: we don’t recommend sharing a cache across multiple Apollo Client instances, particularly in an app that serves authenticated users. This is due to the potential for mixing up data across accounts, which can lead to sensitive information being leaked.

So how do I clear all the caches?

I’m not an Astro user, so I’m not sure I understand the use case enough to recommend something without some more information about your code. Generally speaking, in SSR contexts (non-RSC), we recommend that, on the server side, the InMemoryCache only be used for one request. It should not be long-lived IMO, so there should be no need to reset/clear a cache because it will only last for the duration of the HTTP request.

but the page content is from fetch graphql, if the InMemoryCache only be used for one request, does it re-fetch data on each request on the same page?

This link ( Building Your Application: Caching | Next.js (nextjs.org)) is nextjs cache, you said the InMemoryCache like the Request Memoization cache, but I need the Data Cache, it is store data across user requests and deployments, please any ideas let me know, I’m very need the help.

Well, I set the interval of 1 minute to refetch the graphQL data, but the interval trigger is coding by my myself, I tried the pollInterval on SSR, it not working.