conradkohC
Convex Community2y ago
34 replies
conradkoh

usePaginatedQuery never hits the cache (on the same client)

pagination is often used to reduce the number of rows scanned in the backend, and lazily load rows.

Problem: When applying usePaginatedQuery, the cache is always missed when navigating between pages, that share a convex client.

Example flow:
1. User loads app (convex context at root)
2. User goes to page 1 (load paginated query)
3. User navigates to page 2 (unmount paginated query)
4. User navigates to page 3 (load paginated query) - this misses the cache

Expected result: Paginated query should serve from the cache, based on the page number, across the app.
If users want to always bust the cache, they can add a parameter to args to do it. This also allows more granular control (e.g. embedding the screen name that the user is accessing from) to determine which screens share a cache and which screens don't.

Reference: https://github.com/get-convex/convex-js/blob/250cf7985f5e69817e2b51d4558c166940b870c5/src/react/use_paginated_query.ts#L373-L400
GitHub
TypeScript/JavaScript client library for Convex. Contribute to get-convex/convex-js development by creating an account on GitHub.
convex-js/src/react/use_paginated_query.ts at 250cf7985f5e69817e2b5...
Was this page helpful?