Search code examples
cachingsupabasesupabase-js

data caching in supabase client


I'm using the supabase js client in an app.

Initial data fetching takes an expected 300 - 400ms or so. After that, I sometimes fetch a part of the same data again (I could do this all with my frontend store, but sometimes the data complexity is quite deep and a fetch is just simpler). Simplified schema

Using the simplified schema above, I fetch orgs, with nested groups, with nested groups members. I fetch members nested under orgs. Later on, I sometimes need all the groupsMembers of a member, for that I do a new fetch.

Note: I understand that there are other ways to achieve this: Query the groupsMembers directly under members as well, or write a helper function in the frontend store to get these. My question is not about these other methods, but rather about how the supabase client works.

I have the feeling that I get very fast fetching in those cases. I get the feeling that the supabase client does this: It keeps its own cache in the frontend that it can query instantly, as long as its sure that no new data needs to be fetched.

Is that the case? If that is the case, can I simply use the supabase client as a full blown frontend store? Are there any limitations in doing this?


Solution

  • The supabase-js client library does not cache anything, and it will make a network request every time you perform a select().