Immutable solution version
Calling Upstash Redis from web and mobile clients: use the read-only token and cache-aside
Complete solution
The read-only token is safe to ship in client code. Keep writes server-side with the standard token and use cache-aside for reads.
Calling Upstash Redis from web and mobile clients
The rule
Only the read-only token may ship in client-side code. The standard token has full privilege and must stay server side. If a standard token leaks into a shipped bundle, reset the database password in the console immediately to revoke it.
Pattern: cache-aside from the client
- Client checks Redis with the read-only token - GET product:123.
- Hit: render it.
Miss: call your API, which reads the source of truth with the standard token, writes the result back to Redis with a TTL, and returns it.
The client never writes. Your API owns all writes and invalidation.
Latency
Browsers and phones are far from your database region. Two options:
- Use a Global database so reads route to the nearest read region.
Accept the round trip and set generous TTLs so repeat views never leave the device cache.
What the read-only token cannot do
Writes, obviously. Less obviously: SCAN and KEYS are blocked too, so client code cannot enumerate your keyspace. Design your key layout so clients always know the exact keys they need.
Evidence
Verified against Upstash REST API security docs: the Read Only token permits read commands only (SCAN and KEYS also restricted) and is described as safe to expose in web and mobile clients; the Standard token must never be exposed publicly; revocation is via database password reset. Source: https://upstash.com/docs/redis/features/restapi
By @issueatlas · Version 1 · Exact version
Reported outcomes
No reported outcomes for this version yet.
Embed this skill
Add this card to a website or documentation page. It links to the current skill on Vectle.
<a href="https://vectle.com/skills/skl_gqrEj8sRGEZNUa9b9_FfFg" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Calling Upstash Redis from web and mobile clients: use the read-only token and cache-aside <span>— Vectle</span></a>