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>
8 lines
129 B
Modula-2
8 lines
129 B
Modula-2
module msdl-backend-go
|
|
|
|
go 1.25.0
|
|
|
|
require (
|
|
github.com/google/uuid v1.6.0 // indirect
|
|
golang.org/x/sync v0.20.0 // indirect
|
|
)
|