Skip to content

How to invalidate well

Prefer version-based invalidation for static content, explicit for user data, TTL as fallback.

Invalidation that does not lie

  1. Version the URL, not the cache

    /app.v42.js and /app.v43.js are different resources. No invalidation needed.

  2. Tag by deployment

    Tag every asset with release:42. Purge by tag, not by URL.

  3. Write-then-invalidate, not invalidate-then-write

    Invalidate after the write commits. Otherwise a concurrent read may repopulate with the old value.

  4. Accept some staleness

    If the data is not critical, TTL of 30–60 s is better than complex invalidation logic.