Skip to content

fix: warm homepage metrics cache on first read - #74

Merged
loverustfs merged 1 commit into
mainfrom
codex/warm-homepage-metrics
Aug 2, 2026
Merged

fix: warm homepage metrics cache on first read#74
loverustfs merged 1 commit into
mainfrom
codex/warm-homepage-metrics

Conversation

@loverustfs

Copy link
Copy Markdown
Contributor

fix: warm homepage metrics cache on first read

Copilot AI review requested due to automatic review settings August 2, 2026 04:18
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
rustfs-com e07f5c1 Commit Preview URL

Branch Preview URL
Aug 02 2026, 04:17 AM

@vercel

vercel Bot commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
rustfs-com Ready Ready Preview Aug 2, 2026 4:18am

@loverustfs
loverustfs merged commit 830d2b5 into main Aug 2, 2026
3 checks passed
@loverustfs
loverustfs deleted the codex/warm-homepage-metrics branch August 2, 2026 04:18

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR aims to ensure the homepage metrics KV cache is proactively populated when the /api/homepage-metrics endpoint is first accessed, rather than only via the scheduled refresh.

Changes:

  • Refactors KV reads into readStoredMetrics() and introduces loadOrRefreshHomepageMetrics() to refresh metrics when the stored cache is missing/invalid.
  • Updates the Worker request path to use the new “load or refresh” behavior.
  • Adds a GitHub Actions post-deploy step that calls the metrics endpoint to warm the cache.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
workers/homepage-metrics/src/index.ts Adds “load or refresh” logic and uses it in the fetch handler to warm KV on cache miss.
workers/homepage-metrics/src/index.test.ts Adds unit tests for the new “load or refresh” helper behavior.
.github/workflows/deploy-homepage-metrics.yml Calls the metrics endpoint after deploy to warm the cache.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +227 to +231
const metrics = await loadOrRefreshHomepageMetrics(
() => readStoredMetrics(env),
() => refreshHomepageMetrics(env),
);
return metricsResponse(metrics, request.method);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants