Reduces Microsoft API traffic from thousands/day to ~50-100/day, eliminating the 715-123130 rate-limit block under real traffic. 1. Singleflight (golang.org/x/sync/singleflight) — wraps all Microsoft fetches so 500 concurrent cache misses collapse into 1 API hit. 2. SKU info cache — 7-day TTL keyed by product_id. Language lists are stable; no need to hit Microsoft on every product page load. 3. Download link cache — dynamic TTL keyed by product_id:sku_id. Expiry is derived from the signed URL's `se` query param minus 30min buffer, so we never serve an expired signed URL. 4. Negative response caching — 60s TTL for 429 / 715-123130 failures. Prevents thundering herd from retries worsening an existing block. Only stored when no stale data is available to fall back on. 5. Dynamic TTL — parses `se` (signed expiry) from Microsoft CDN URL: TTL = (se - now) - 30min. Falls back to 22h if unparseable. 6. Stale-on-failure — if a refresh fails (rate-limited or transient), the expired cache entry is served temporarily. Applies to both /proxy (download links) and /evallinks (eval ISOs). 7. Jitter — ±5min random offset on all TTLs prevents synchronised mass-expiry spikes when many entries are warmed at the same time. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
4 lines
318 B
Text
4 lines
318 B
Text
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
|
|
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
|
golang.org/x/sync v0.20.0 h1:e0PTpb7pjO8GAtTs2dQ6jYa5BWYlMuX047Dco/pItO4=
|
|
golang.org/x/sync v0.20.0/go.mod h1:9xrNwdLfx4jkKbNva9FpL6vEN7evnE43NNNJQ2LF3+0=
|