Caching feed responses end to end

Where Redis, CDN, and in-memory caches sit between Arduino JSON and the browser—and TTL tuning per layer.

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.

Cache layers from browser to edge to relay Redis to Arduino
TTL settings at relay Redis and edge fetch boundaries balance freshness versus uplink load.

Layer guide

  • Redisprimary 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

  1. Measure curl latency from edge to relay.
  2. Set TTL ≥ Arduino poll interval.
  3. Verify LCD vs web after changes—LCD is often fresher.