mirror of
https://github.com/koala73/worldmonitor.git
synced 2026-05-13 10:36:21 +02:00
* perf(relay): add upstream compression, keep-alive, brotli, and OREF pre-serialization
1. OpenSky upstream: request gzip/br/deflate via Accept-Encoding header
and decompress responses, reducing inbound transfer on cache misses
2. HTTPS keep-alive agent: reuse TCP+TLS connections to OpenSky,
eliminating ~2-5KB handshake overhead per request
3. Brotli support: sendCompressed and sendPreGzipped now prefer br
encoding (~15-20% smaller than gzip on JSON). Pre-computed brotli
buffers stored alongside gzip in all caches (OpenSky, AIS snapshot)
4. OREF pre-serialization: pre-compute alerts and history JSON + gzip +
brotli buffers on each poll, switching handlers from on-the-fly
sendCompressed to zero-CPU sendPreGzipped
All changes reduce proxy egress volume (charged by volume).
* fix(relay): re-serialize OREF cache on poll failure
Ensures _alertsCache reflects lastError when a poll fails,
so /oref/alerts clients see the error instead of stale
success data. Addresses Codex P1 review comment.
* fix(relay): reject on decompression failure and honor Accept-Encoding q-values
P1: _collectDecompressed now rejects on stream error instead of
resolving with partial data. Callers in _openskyRawFetch catch the
rejection and return { status: 0, error }, preventing malformed
responses from being cached as valid 200s.
P2: Replace naive includes('br')/includes('gzip') with
_acceptsEncoding() that parses q-values. A client sending
br;q=0 will no longer receive Brotli-encoded responses.