Learn

VISUAL GUIDE · SCALING & CACHING

Where a cache helps (and where it lies)

Step 2 of 9: Ask a cache first

STEP 2 / 9ORIGINAL SKETCH
GET /abc123get, set on missread alias302 LocationBrowserRedirect serviceAlias cacheTTL 60 sAlias storesource of truth
A browser asks a redirect service for a short link; the service checks a cache, falls back to the alias store on a miss, checks a disabled list, and a link owner or moderator can edit the store, purge the cache, or disable a link.
2 / 9
  1. No cache
  2. Add a cache
  3. Cache hit
  4. Cache miss
  5. Link changes
  6. Stale hit
  7. TTL bounds it
  8. Purge
  9. Deny-list

STEP 2 OF 9 · ADD A CACHE

Ask a cache first

Put an in-memory alias cache next to the redirect service. The service checks the cache before the store. This pattern, where the application reads the cache and fills it itself, is usually called cache-aside.

Each entry carries a TTL of 60 seconds. After that the entry expires and the next request goes back to the store.

Why it matters. The cache is a copy. Deciding where the copy lives and how long it may be trusted comes before choosing any cache product.