9 Replies
I too have been wondering about this.. It would be a tricky one to do I suspect?
I think they should be cached. Are you observing that they don't get cached?
I had a function in dev that I switched to paginated and caching seems to have stopped. But I just checked and my main paginated query in production does get cached, so not sure what I did to upset the one I'm working on.
My understanding is that, if inputs don't change, I get a cached response, but there has to be other variables. Some queries get cached reliably and others just don't. It seems the more busy a query is the more likely it is to not produce cached responses, even if the inputs are simple and don't change.
it's a function of inputs and the data accessed by the query. basically the same "realtime subscription" feature of
useQuery
is also used on the server to invalidate the cacheOkay. Is it possible that indirection in the actual
ctx.db
calls (calling a function that calls a function that calls a function vs calling direct) can somehow impact this?how you call
ctx.db
shouldn't matter, although layers of indirection could hide things. like if you're doing security checks against ctx.auth
, the query will only be cached for that auth.Does calling
auth.getUserIdentity()
count as a security check? That's my only interaction with the auth object I believeif you call
auth.getUserIdentity()
, then your query depends on the authenticated user and the query won't be cached across usersThat's what I figured. The misses I'm seeing are for a single user. Maybe not much to assess here, I'll circle back when I have wide usage and meaningful data.