Skip to content

Tag-based cache invalidation worker #94

@tayebmokni

Description

@tayebmokni

Summary

Implement the invalidation-worker Asynq worker per doc 07 §16.2 that tails the cache_invalidations outbox table. For each row it (1) calls FragmentCache.InvalidateTags, (2) POSTs to the Next.js /api/revalidate webhook, (3) purges Cloudflare cache-tags via API, then (4) deletes the row. Failures are retried with exponential backoff. Crash-safe: if the worker dies mid-run, the row remains and the next invocation picks it up.

Design reference

  • docs/07-media-performance.md §16.1, §16.2, §16.3

Acceptance criteria

  • Worker tails cache_invalidations rows in order
  • For each row: invoke Fragment cache + Next.js webhook + Cloudflare API in sequence
  • Row deleted only after all three succeed
  • Exponential backoff on transient failures; circuit-breaker on Cloudflare API
  • Replay-safe: re-running on a row produces the same invalidation
  • Canonical tag vocabulary enforced (post:{uuid}, term:{uuid}, user:{uuid}, type:{slug}, archive:..., media:{uuid}, nav:{uuid}, site:settings, global)
  • Tests cover worker restart mid-row and partial failures

Dependencies

#fragment-cache, #isr-webhook

Complexity

M

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:cacheCache layers + invalidationarea:jobsBackground jobs, cronarea:workerBackground workers (Asynq)phase:P3-themesPhase 3 — Themespriority:P1Important — should land in phaseskill:goGo programmingtype:featNew feature or implementation task

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions