Apollo Client Caching Explained
The Apollo Client cache is a normalized, in-memory store. Apollo Client, known for its powerful GraphQL handling, incorporates an advanced caching system to boost application performance by minimizing unnecessary network requests. Below are key features and techniques for client-side caching with Apollo:
InMemoryCache
The default caching solution, InMemoryCache, stores normalized data in memory to eliminate redundancy and enhance lookup speeds.
Normalized Apollo Client Cache
By breaking down query results into individual objects and storing them flatly by unique identifiers, Normalized Cache ensures efficiency in data updating and retrieval.
Cache Redirects
Cache Redirects guide Apollo’s cache to fetch data for certain queries from already cached information, even if stored under different queries.
Field Policies
Custom logic for cache operations at the field level can be defined through Field Policies, allowing for tailored caching strategies, pagination, and more.
Cache Eviction and Garbage Collection
Tools for Cache Eviction and Garbage Collection aid in maintaining an optimal cache size by purging unused or stale data.
Persisted Cache
With Persisted Cache, data can be stored in local storage or other mediums, enabling quick data retrieval even after application restarts.
Optimistic UI
The Optimistic UI feature allows for instant UI updates with hypothetical... premium content.
