Clever Tagline
Clever Tagline4mo ago

Another question about Convex caching,

Another question about Convex caching, this time related to the built-in caching of queries on the back end. Say I run a given query multiple times in relatively quick succession; e.g. I'm flipping between routes in my Remix app, and each route runs a different query. The data isn't changing between route changes, so the later queries return cached data. How do those cached query returns impact my bandwidth stats? In other words, if Convex returns cached data for a query, does that still count towards my bandwidth, or is the bandwidth only affected when a query returns non-cached data?
3 Replies
Hmza
Hmza4mo ago
The bandwidth usage and associated costs are only impacted when: A query needs to fetch fresh data from the database (i.e., a cache miss). The underlying data has changed, causing the cache to be invalidated and requiring a fresh database read. "Convex automatically caches the result of your query functions so that future calls just read from the cache. The cache is updated if the data ever changes. You don't get charged for database bandwidth for cached reads."1 Ref: https://docs.convex.dev/realtime
Realtime | Convex Developer Hub
Building realtime apps with Convex
lee
lee4mo ago
+1 cached queries don't count database bandwidth, although they do count as "function calls"
Clever Tagline
Clever TaglineOP4mo ago
Thanks for the clarification!

Did you find this page helpful?