warmbowski
warmbowski2w ago

Caching Solutions?

I'm creating an audio transcript app for audio that is typically about 2 hours long. When I get the transcipt, it is in a form chunked by speaker, and I put each chunk in a convex table. No problem from the ingress perspective, but when viewing in the web, I blow away the free tier of DB Bandwidth pretty quickly. This wouldn't be the case if this data was cached in the browser (can't wait for the local-first sync solution). The data comes in over websockets so it doesn't get cached and if I reload the page or load another transcript, it just gets the data again from the DB. This data will never change once it's written to the DB. The only caching solution I can think of is to move this query into an HTTP Action and let it get cached like any other http response. I am posting here to hear from other folks who have contended with this and have caching solutions to reduce DB bandwidth.
2 Replies
Convex Bot
Convex Bot2w ago
Thanks for posting in <#1088161997662724167>. Reminder: If you have a Convex Pro account, use the Convex Dashboard to file support tickets. - Provide context: What are you trying to achieve, what is the end-user interaction, what are you seeing? (full error message, command output, etc.) - Use search.convex.dev to search Docs, Stack, and Discord all at once. - Additionally, you can post your questions in the Convex Community's <#1228095053885476985> channel to receive a response from AI. - Avoid tagging staff unless specifically instructed. Thank you!
warmbowski
warmbowskiOP2w ago
Welp. no responses. BUT!! I think I have a solution and will see how it goes. Since I am wrapping my convex queries in useQuery from @tanstack/react-query, I am going to set up the PersitedQueryClientProvider and persist the cache to indexeddb. I got it set up and it seems to work pretty good. The first fetch gets all the data, but then a page refresh doesn't rerun the query function but just pulls in the cached data. Here's a link to the basic docs on the persistQueryClient, so you can get the jist of it, but if you want to try it out, remember to configure the queryClient properly for convex queryKeyHashFn and queryFn. I'm going to mark this resolved and just see how things go. Please respond to this thread if you end up trying this yourself.
persistQueryClient | TanStack Query React Docs
This is set of utilities for interacting with "persisters" which save your queryClient for later use. Different persisters can be used to store your client and cache to many different storage layers....

Did you find this page helpful?