Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

global cache? #7

Closed
ianstormtaylor opened this issue Oct 28, 2019 · 2 comments
Closed

global cache? #7

ianstormtaylor opened this issue Oct 28, 2019 · 2 comments
Labels

Comments

@ianstormtaylor
Copy link

Is the key cache global? How does it handle conflicts if it's used in multiple contexts?

@pacocoursey
Copy link
Contributor

Yes, the key cache is global across all useSWR calls.

How does it handle conflicts

Your cache keys shouldn't conflict, otherwise the cache isn't very useful. We've found that using the URL of the API you're calling to be good keys.

used in multiple contexts

If you have useSWR calls in multiple places that use the same key, the data is shared and updated in all contexts. This makes it easy to synchronize data between multiple pages that use the same data sources.

@crossjs
Copy link

crossjs commented Oct 26, 2020

Yes, the key cache is global across all useSWR calls.

useSWR share states between multiple calls in same next.js page.
but, useSWR does NOT share states between multiple next.js pages,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants