Skip to content

feat(proxy): add Cloudflare edge caching for proxy.worldmonitor.app#478

Merged
koala73 merged 1 commit into
mainfrom
feat/proxy-edge-caching
Feb 27, 2026
Merged

feat(proxy): add Cloudflare edge caching for proxy.worldmonitor.app#478
koala73 merged 1 commit into
mainfrom
feat/proxy-edge-caching

Conversation

@koala73

@koala73 koala73 commented Feb 27, 2026

Copy link
Copy Markdown
Owner

Summary

  • Add CDN-Cache-Control headers to all proxy endpoints (/rss, /ucdp-events, /opensky, /worldbank, /polymarket, /telegram, /ais/snapshot) enabling Cloudflare edge caching independently of browser Cache-Control
  • Fix Vary header merging in sendCompressed/sendPreGzipped — was overwriting Vary: Origin with Vary: Accept-Encoding, now properly merges both to prevent cross-origin cache poisoning
  • Add Cache-Control: no-store + CDN-Cache-Control: no-store to all stale fallback and error responses to prevent edge caching of degraded data

Edge TTLs

Endpoint Browser Edge Notes
/rss 300s 600s + SWR 300s Longer edge, stale-while-revalidate
/ucdp-events 3600s 3600s Matches browser
/opensky 30s 15s Shorter edge for fresher flight data
/worldbank (data) 1800s 1800s Matches browser
/worldbank (indicators) 86400s 86400s Static data
/polymarket 120s 120s Matches browser
/telegram 10s 10s Matches browser
/ais/snapshot 2s 2s Matches browser

Cloudflare Dashboard (manual post-deploy)

Create a Cache Rule for proxy.worldmonitor.app:

  • Match: Hostname equals proxy.worldmonitor.app + URI path in allowlist (/rss, /ucdp-events, /worldbank, /polymarket, /telegram, /opensky, /ais/snapshot)
  • Exclude: /opensky-reset, /opensky-diag
  • Setting: Eligible for cache, respect origin CDN-Cache-Control

Test plan

  • Deploy to Railway staging
  • Verify CDN-Cache-Control header present on authenticated requests
  • Verify cf-cache-status: HIT on second request after Cloudflare Cache Rule is active
  • Verify stale fallback responses have no-store (not edge-cached)
  • Verify /opensky-reset and /opensky-diag are not edge-cached
  • Verify Vary header includes both Origin and Accept-Encoding

Add CDN-Cache-Control headers to all proxy endpoints so Cloudflare can
cache responses at the edge independently of browser Cache-Control:

- RSS: 600s edge + stale-while-revalidate=300 (browser: 300s)
- UCDP: 3600s edge (matches browser)
- OpenSky: 15s edge (browser: 30s) for fresher flight data
- WorldBank: 1800s/86400s edge (matches browser)
- Polymarket: 120s edge (matches browser)
- Telegram: 10s edge (matches browser)
- AIS snapshot: 2s edge (matches browser)

Also fixes:
- Vary header merging: sendCompressed/sendPreGzipped now merge existing
  Vary: Origin instead of overwriting, preventing cross-origin cache
  poisoning at the edge
- Stale fallback responses (OpenSky, WorldBank, Polymarket, RSS) now
  set Cache-Control: no-store + CDN-Cache-Control: no-store to prevent
  edge caching of degraded responses
- All no-cache branches get CDN-Cache-Control: no-store
- /opensky-reset gets no-store (state-changing endpoint)
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@vercel

vercel Bot commented Feb 27, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
worldmonitor Building Building Preview, Comment Feb 27, 2026 6:04pm
worldmonitor-finance Building Building Preview, Comment Feb 27, 2026 6:04pm
worldmonitor-happy Building Building Preview, Comment Feb 27, 2026 6:04pm
worldmonitor-startup Building Building Preview, Comment Feb 27, 2026 6:04pm

Request Review

@koala73
koala73 merged commit aff3cfc into main Feb 27, 2026
3 of 5 checks passed
koala73 added a commit that referenced this pull request Mar 1, 2026
…478)

Add CDN-Cache-Control headers to all proxy endpoints so Cloudflare can
cache responses at the edge independently of browser Cache-Control:

- RSS: 600s edge + stale-while-revalidate=300 (browser: 300s)
- UCDP: 3600s edge (matches browser)
- OpenSky: 15s edge (browser: 30s) for fresher flight data
- WorldBank: 1800s/86400s edge (matches browser)
- Polymarket: 120s edge (matches browser)
- Telegram: 10s edge (matches browser)
- AIS snapshot: 2s edge (matches browser)

Also fixes:
- Vary header merging: sendCompressed/sendPreGzipped now merge existing
  Vary: Origin instead of overwriting, preventing cross-origin cache
  poisoning at the edge
- Stale fallback responses (OpenSky, WorldBank, Polymarket, RSS) now
  set Cache-Control: no-store + CDN-Cache-Control: no-store to prevent
  edge caching of degraded responses
- All no-cache branches get CDN-Cache-Control: no-store
- /opensky-reset gets no-store (state-changing endpoint)
koala73 added a commit that referenced this pull request Mar 1, 2026