Menu

Our data version is one number, and it is also the ETag, the cache key and the thing that stops a phone going backwards
📰

Our data version is one number, and it is also the ETag, the cache key and the thing that stops a phone going backwards

DEV Community: nextjs·Daniel Pertu·about 2 hours ago
#iuu8cTD8
#devtonextjs#devto#dev#version#snapshot
Reading 0:00
15s threshold

Munchable's app reads a product label and tells you whether that product suits your gut. The part of it that improves most often is not the code, it is the ingredient data: new words, new spellings, new names for the same thing. Shipping that through the app stores would mean a release per data fix, so instead the app downloads a snapshot of it and keeps a copy on the device.

That means I need an answer to a question that comes up more often than you would think: has this phone's copy gone stale?

The answer is one number.

max(updated_at) over every active row of both tables, as an epoch-ms decimal string. '0' when empty. One number for the whole snapshot.

Enter fullscreen mode

Exit fullscreen mode

That string is the version. It is also the ETag . It is also the value of an x-taxonomy-version response header on other endpoints, and the key the server caches under.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.