Skip to content
This repository has been archived by the owner on Apr 27, 2022. It is now read-only.

Fetch policy: cache-first, cache-and-network and network-only #317

Merged
merged 9 commits into from
Apr 28, 2020

Conversation

ArnaudWeyts
Copy link
Contributor

Added

  • A new option: fetchPolicy
    • cache-first: will look at the cache and return the cached value or send a request
    • cache-and-network: returns cached data immediately, but also sends a request to refresh it
    • network-only (previously ignoreCache = true): ignores the cache and always sends network requests

The default value is cache-first unless ignoreCache is set to true, in which case fetchPolicy will default to network-only

this is a remnant of the old queries implementation
it will replace the ignoreCache option in the next minor version
this way we preserve backwards compatibility, this will be removed in the next minor version bump
cache-first and cache-and-network will both set the initial state from the global store, otherwise the initial state is empty
cache-first will not send a request, cache-and-network will set the cached state, and send a request, network-only will not take the cache into account
the data will already be set by the initial state
@ArnaudWeyts ArnaudWeyts added the feature Feature requests label Apr 28, 2020
@ArnaudWeyts ArnaudWeyts self-assigned this Apr 28, 2020
@ArnaudWeyts ArnaudWeyts merged commit 9250c66 into next-release Apr 28, 2020
@ArnaudWeyts ArnaudWeyts deleted the feature/fetch-policy branch April 28, 2020 15:08
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature Feature requests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant