⬡ GraphQL Intermediate

What is the difference between network-only, cache-first, and cache-and-network fetch policies?

Answer

Apollo Client's fetch policies control how queries interact with the cache. cache-first (default): read from cache; only fetch from network if data is not cached. Best for stable data. network-only: always fetch from network; result is stored in cache for future queries but cache is never used for the current query. Best for frequently changing critical data. cache-and-network: returns cached data immediately (fast render), then fetches from network and updates if data changed. Good balance for most use cases. no-cache: always fetch from network; result is NOT stored in cache. For sensitive/one-off queries. cache-only: only read from cache; error if not cached. For offline-first apps. standby: like cache-first but doesn't update on cache changes. Set per query: useQuery(QUERY, { fetchPolicy: 'network-only' }).