Enforcing link expiry at read time instead of relying on a background sweeper
A developer building a short-link service added an optional time-to-live after users requested temporary links for event invites, one-time documents, and agent handoffs. The first approach used a periodic sweeper to delete expired rows, but this made the database the source of liveness and introduced timing gaps. The redesign checks expiry at read time, with the sweeper serving only as a garbage collector for already-expired rows. The redirect handler returns the same 410 response whether a link never existed or has expired, so callers cannot distinguish the two cases. The author notes that links still expire correctly even when the sweeper is not run, and presents the approach as a general principle for ephemeral resources.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in