mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-13 14:32:03 +00:00
The targets endpoint runs >1 s cold — pulls 30 days of measurements for every type plus medications, intakes, mood and glucose to build the consistency strips, streaks and target-met-this-week rollup. It's read on every Insights mount and on every sub-page click, so the cumulative cost dominates a power user's session. Wrap the body in the existing analytics-style server cache with a 60 s TTL and a per-user key. The invalidation helpers for measurement, mood and medication writes evict the user bucket so the next read paints fresh data without the cache lagging the underlying state. The bfcache-friendly Cache-Control header lets a back-forward navigation restore from the BFCache instead of repaying the cost.