I have a NextJS app for which I want to cache data from our backend APIs to reduce the load when we have high volumes of concurrent users scrolling through (or search) years-worth of historical data.
Data flow is unidirectional with the cache only ever being updated via our APIs. Cached data is eventually consistent. Ideally this cache/database would also support join queries.
One potential solution is a SQLite database stored on the user's device via Origin Private File System. Limitations include the complexity/memory usage of loading up the DB via WASM and web workers, the DB being wiped away when browser data is cleared (and thus needing to be re-populated which puts a strain on our APIs), as well as the fact that we'd need to refactor our app such that much of the server-side components would be pushed into the client.
I am also exploring server-side caching solutions however this would be more expensive to scale, in addition to increasing latency when an update occurs via the client.
-
looks interesting, you can use local storage and or cookies but the space is limitedEwan– Ewan2024年03月31日 13:39:56 +00:00Commented Mar 31, 2024 at 13:39
-
The crux of the problem is the definition of real-time. Once you define the acceptable timespan, you can pick your caching solution based on the required performance target.Ccm– Ccm2024年04月01日 00:21:31 +00:00Commented Apr 1, 2024 at 0:21