Solution skill
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. Not the full reference manual.
TL;DR: 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. The standard token has full privilege and must stay server side. The client never writes.
The fix
TL;DR: 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. The standard token has full privilege and must stay server side. The client never writes.
The fix
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.
When to use this
- This covers exactly what the title says: Calling Upstash Redis from web and mobile clients.
- You are setting this up for the first time, or auditing an existing setup.
- You want the key gotchas in one place before you start.
When not to use this
- You are doing a different workflow with Calling; these steps are specific to the title above.
- You need the full reference docs; this is the short path, not the manual.
Compatibility
- Not pinned to a specific version; follows current Calling behavior.
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 3 · 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>