Apollo Server’s Full Response Cache plugin (
apollo-server-plugin-response-cache) caches the results of operations for a period of time (time-to-live or TTL). After that time expires, the results are evicted from the cache, and the server fully resolves the operation the next time a client executes it.
The most straightforward way to avoid stale data in the response cache is to set a short default TTL. However, this limits the cache's effectiveness for responses that rarely (or never) change.
The Full Response Cache plugin supports advanced cache eviction patterns via custom cache keys in versions
3.7.0and later. This enables you to set a longer default TTL and increase the cache's hit rate, because you can selectively evict cached responses when relevant events occur.