テーマ: caching
-
Rolling out a service worker safely: scope, versioned caches, the waiting worker and a kill switch
A service worker that caches HTML can pin users to old code after a deploy. Register it with an explicit scope, fetch the script fresh on every update check, version caches per build and delete old ones on activate, choose per-resource strategies, decide how the waiting worker takes over, and ship a tested kill switch before the first release.
-
Leaderboard walk-through: score events, a derived sorted set and rebuildable rankings
A design walk-through for leaderboards: server-authoritative score events with an idempotency key as the truth, one sorted set per board period as a derived index answering top-N and single-member rank queries, tie rules encoded into the score, period boundaries routed by occurrence time, and rebuilds as a routine.
-
Cache-Control directives: max-age, no-store, private and stale-while-revalidate
Cache-Control tells browser and shared caches how long a response may be reused and where it may be stored: max-age and s-maxage set freshness, no-cache forces revalidation before reuse, no-store forbids storage, private keeps a response out of shared caches, and stale-while-revalidate and stale-if-error (RFC 5861) let a cache serve stale content while refreshing or during errors. A response without directives may still be cached heuristically.
-
Use conditional GETs for changing feeds
Cache a feed representation with its validator and reuse it correctly after a 304 without mixing users, languages or query variants.
機械可読: JSON