create_app() in src/mk_tracking/ui_app/app.py warms the cache exactly once, in the lifespan handler:
try:
repo.list_issues()
repo.list_mks()
repo.preload_summaries()
except Exception as error:
print(f"Cache pre-warm warning: {error}")
Two consequences follow.
Data is as old as the process. Once the app is running, nothing ever refreshes it. A long-lived process serves whatever the dataset looked like at boot. On a site that makes claims about what elected officials said, silently serving stale positions is worse than being briefly unavailable.
A failed pre-warm degrades quietly. The except prints a warning and carries on, so the app starts with a cold cache and every subsequent request runs the full BigQuery query synchronously.
What to build
- A TTL or periodic background refresh, so cached data has a bounded age.
- A way to see cache age — a field on the health endpoint is enough.
- Retry or fail-fast on startup rather than proceeding cold, so a broken pre-warm is visible instead of turning into a slow site.
This becomes more pressing once the pipeline runs on a schedule rather than by hand — see the self-hosting issue.
create_app()insrc/mk_tracking/ui_app/app.pywarms the cache exactly once, in the lifespan handler:Two consequences follow.
Data is as old as the process. Once the app is running, nothing ever refreshes it. A long-lived process serves whatever the dataset looked like at boot. On a site that makes claims about what elected officials said, silently serving stale positions is worse than being briefly unavailable.
A failed pre-warm degrades quietly. The
exceptprints a warning and carries on, so the app starts with a cold cache and every subsequent request runs the full BigQuery query synchronously.What to build
This becomes more pressing once the pipeline runs on a schedule rather than by hand — see the self-hosting issue.