Handling cache when scaling multiple instances

Hi,

I was wondering how do you guys handle the clearing of the cache for a client when you scale your application to multiple instances?

For example, in my scenario I am using apollo server mongodb datasource library and on the client side I use the regular in-memory cache.

I am able to effectively clear or reset the cache on both GraphQL and the client side.
But I noticed that I will get into issues when scaling to multiple instances because the cache is only cleared for the instance itself and the client communicating with that instance of the GraphQL server.

I was wondering how do you guys handle this usually?

Any help is appreciated, thanks!

Which Apollo client are you referring to here, Web, iOS, or Android/Kotlin?

Sorry about that, on the client side I am using the Web version of the client.

Update: I decided to implement Redis as a cache for GraphQL using the following doc:

Configuring cache backends - Apollo GraphQL Docs

In order to notify my front-end, I implemented a Subscription, for this I also used Redis as the production pubsub library.

Subscriptions in Apollo Server - Apollo GraphQL Docs

Which my front-end subscribes to and listens for changes and then evicts the cache using client.evict.

Garbage collection and cache eviction - Apollo GraphQL Docs