When revalidateOnMount = false, requests are never made
See original GitHub issueI configured globally revalidateOnMount = false and no requests are made. Doing a request for the first time when there is no cache yet should not be considered re-validation since there is no “re…” in that action. At least a request should be made on first mount.
In my project I want my requests to only be sent when there is no cache, in other words: after the first call to useSwr() I want all the the following useSwr() to use the cache during all the life time of the application, or until I call mutate(). This is the correct behavior in applications when data is not required to be up to date. I can’t figure out a global configuration where I can set this behavior, is it possible?
This is my global configuration:
{
refreshInterval: 0,
errorRetryCount: 0,
shouldRetryOnError: false,
revalidateOnMount: false,
revalidateOnFocus: false,
revalidateOnReconnect: false,
compare: (a, b) => a === b
}
I’m very surprised about having to search for this or open an issue because of this, maybe I’m doing something that nobody should do or something like that. Also I can’t figure out what is the use case for the current revalidateOnMount = false, who would ever need a useSwr() that does nothing?
Issue Analytics
- State:
- Created 3 years ago
- Reactions:15
- Comments:15 (2 by maintainers)
What is the difference between
revalidateOnMount
andrevalidateIfStale
? I don’t really get it from the docs.Yeah I’ve been thinking about this too, that’s why I opened #992 specifically for this case: don’t fetch if cached.
I will try to add it in 1.0 soon, it would be great to hear more community feedback for it.