Skip to content

Cache#533

Open
xsuchy wants to merge 2 commits into
packit:mainfrom
xsuchy:cache
Open

Cache#533
xsuchy wants to merge 2 commits into
packit:mainfrom
xsuchy:cache

Conversation

@xsuchy

@xsuchy xsuchy commented Jun 5, 2026

Copy link
Copy Markdown

TODO:

  • [-] Write new tests or update the old ones to cover new functionality.
  • Update doc-strings where appropriate.
  • [-] Update or write new documentation in packit/packit.dev.

Added server-side daily caching for the usage page. Flask proxies usage API calls, caches responses as files in /tmp, and a background loop refreshes them at 00:01 daily. Both commits are done, nothing pending. (disable recaps in /config)

RELEASE NOTES BEGIN

Dashboard statistics are now cached on the server side for all processes together and pre-generated automatically after midnight.

RELEASE NOTES END

xsuchy added 2 commits June 5, 2026 22:39
Usage page data changes infrequently and is expensive to fetch from
the upstream API. Flask now proxies /api/usage/ requests and caches
responses as JSON files in /tmp/packit-dashboard-usage-cache/, keyed
by endpoint and date. All WSGI workers share the same file-based
cache. Stale files from previous days are evicted on cache miss.

Frontend fetches usage data from the Flask proxy (same origin) instead
of the external API directly. Tabs render all content eagerly (removed
mountOnEnter) so all data loads upfront. Vite dev server proxies
/api/usage to localhost Flask for local development.

- Flask proxy with file-based daily cache over in-memory dict to share
  across WSGI workers
- Frontend switched from VITE_API_URL to relative /api/usage/ paths
- All tabs rendered immediately instead of on-demand

Assisted-By: Claude Opus 4.6 <noreply@anthropic.com>
Extract cache logic into cache.py module shared by Flask routes and
the new warm_cache.py script. The startup script pre-warms the cache
on boot and schedules a background loop that re-fetches all usage
endpoints at 00:01 each day.

- No crond needed — background sleep loop in run_httpd.sh calculates
  seconds until next 00:01 and sleeps precisely
- Cache files in /tmp shared across WSGI workers, warm_cache populates
  them before any user request hits

Assisted-By: Claude Opus 4.6 <noreply@anthropic.com>
@centosinfra-prod-github-app

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

2 participants