A single home page view could otherwise trigger a LAN fetch from Cloudflare to your residential relay on every request. Caching at the Python relay (Redis), optional edge cache headers, and short in-process memoization in Astro each reduce load. Mis-tuned TTL causes stale readings that look like hardware faults.
Layer guide
- Redis — primary TTL 30–120s at relay.
- Astro fetch — optional short memo during single SSR request.
- CDN — avoid caching authenticated HTML; public home may cache briefly.
Stale-while-revalidate
Serve last good JSON while async refresh runs if Arduino is slow—documented in health checks. Do not cache error bodies. Probe insert logic should skip failed fetches per history inserts.
Tuning workflow
- Measure curl latency from edge to relay.
- Set TTL ≥ Arduino poll interval.
- Verify LCD vs web after changes—LCD is often fresher.