Files
worldmonitor/scripts
Elie Habib 560fb685aa fix(relay): stop Polymarket cache stampede from concurrent limit + CDN bypass (#592)
Three issues caused continuous MISS every 5 seconds:

1. Concurrent limit rejection poisoned cache: 11 tags fire via Promise.all
   but POLYMARKET_MAX_CONCURRENT=3, so 8 tags got negative-cached with
   empty [] (5 min TTL). Those 8 tags NEVER got positive cache because
   they were always throttled. Fix: replace reject-with-negative-cache
   with a proper queue — excess requests wait for a slot instead of
   being silently rejected.

2. Cache key fragmentation: fetchPredictions(limit=20) and
   fetchCountryMarkets(limit=30) created separate cache entries for the
   same tag. Fix: normalize to canonical limit=50 upstream, cache key
   is shared regardless of caller's requested limit.

3. CDN bypass: end_date_min timestamp in query string made every URL
   unique, preventing Vercel CDN caching entirely. Fix: strip
   end_date_min, active, archived from proxy params (relay ignores them
   anyway).
2026-03-01 00:46:53 +04:00
..