Serve stale API responses when DeviantArt blocks, and back off !27

merged merged by cmc on 2026-09-11 18:55 UTC · krz/skunky-art:feat/stale-on-block into main

Discussion

cmc

From the art.krz.sh incident: when DeviantArt bans the egress address every DA-backed page 502s until someone restarts the stack.

  • Entries past ttl are kept for api-cache.stale (default 1h, 0i disables) and served when the fetch fails or answers 403/429. The daily deviations, popular searches and feeds stay up through a short ban.
  • A 403/429 starts a one minute backoff: misses with nothing stale get the block response back with no upstream call, so a banned instance stops hammering the WAF.
  • Stats line gains a "served stale" count. SETUP.md documents stale.

Five new tests over a controllable clock: stale on block, stale on transport error, backoff skips upstream then recovers, stale dropped after the window, stale 0 keeps nothing. One existing test now uses a 500, since a 403 is a block.