apolloapollo-clientapollo-server

What is the default Apollo Client query cache TTL?


I use Apollo Client/Server through a React/Next app with in-memory cache enabled with the default cache strategy, I guess it's cache-first.

I'd like to know what is the default Apollo cache TTL? In other words, how much time do I need to wait for the updated data to get to the client?

Tried to find this information in the documentation but no luck.

Thanks in advance.


Solution

  • After looking for it too I finally found it. Apollo Server's default in-memory store does not have a TTL, the queries stay cached forever until they're overwritten. However, for all other supported stores, the time to live is set to 300 seconds by default.

    https://www.apollographql.com/docs/apollo-server/performance/apq/#adjusting-cache-time-to-live-ttl

    Apollo Server's default in-memory store does not specify a TTL for APQs (an APQ remains cached until it is overwritten by the cache's standard eviction policy). For all other supported stores, the default TTL is 300 seconds. You can override or disable this value by setting the ttl attribute of the persistedQueries option, in seconds: