THE PROBLEM
Follow a short-link redirect through a cache hit, a miss and a stale answer, then see how TTLs, purges and a deny-list keep the cache honest.
A short link goes viral and thousands of browsers ask for the same redirect every second. Every request reads the same row from the alias store, which starts to slow down. A cache will fix the load, but the first time someone changes or disables a link, the cache will keep serving the old answer. Follow a redirect through each case and decide how wrong the cache is allowed to be, and for how long.
By the end you can
- Trace a cache hit and a cache miss on a read path, including who fills the cache.
- Explain why a cached answer can be stale and what bounds how long it stays wrong.
- Order the steps of a change correctly: write the source of truth, then purge.
- Explain why a takedown needs a check that runs on every request, not just a purge.
- Pick a TTL by asking how long a wrong answer is acceptable, not how fast the cache is.
Assumptions behind the numbers
- Illustrative: a cache read takes about 1 ms and an alias store read about 8 ms inside one data centre. Real numbers vary; measure your own.
- Illustrative: a viral link peaks around 4,000 redirects per second, nearly all for one alias.
- Our URL shortener worked approach treats mappings as permanent and only disables them. This guide lets owners edit a link's target so a stale cache entry is easy to see.
- The cache TTL is 60 seconds. That number is a product decision about acceptable staleness, not a performance setting.