Post

Zero’s sync engine is query-based. Rather than specifying what to sync with rules or some separate system, you use queries. Right inside the client app, you do queries using a full sql-style language. You get filters, subqueries , limits, etc. Zero syncs the data for these queries to the client.

It’s important to realize because of this syncing, Zero isn’t really a cache. It’s a replica. It’s eagerly replicating a slice of your database - the slice covered by the queries you have open. So there's never stale data in Zero. When you close a query, we delete its rows so they don't go stale.

Of course that kind of sucks for the common case of doing a query, navigating, then pressing “back”. Ideally we want that to be fast. To address this Zero 0.17 adds background queries. You can add a ttl to a query and it will keep running and syncing in the background.

This is much different than normal caching because this data stays up to date. If you make the same query again, the results will be *instantly* available *and already up to date with server*.