[PR #34] [MERGED] Fresh GitHub data within a minute: revalidate on Kira's call #36

Closed
opened 2026-11-03 04:02:33 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon-site/pull/34
Author: @ludovic111
Created: 11/1/2026
Status: ✅ Merged
Merged: 11/1/2026
Merged by: @ludovic111

Base: main ← Head: feat/revalidate-on-push


📝 Commits (2)

  • 57cb79b Revalidate GitHub data on Kira's call: fresh within a minute of a push
  • 3314bf9 Read GitHub's REST API through Kira's proxy, straight from GitHub as a fallback

📊 Changes

11 files changed (+153 additions, -34 deletions)

View changed files

📝 CLAUDE.md (+1 -1)
📝 README.md (+10 -0)
➕ app/api/revalidate/route.ts (+33 -0)
📝 components/contributors.tsx (+5 -5)
📝 components/docs-data.ts (+4 -2)
➕ components/github-api.ts (+30 -0)
➕ components/github-fresh.ts (+38 -0)
📝 components/github-releases.ts (+5 -5)
📝 components/hub-data.ts (+9 -9)
📝 components/journal-feed.ts (+13 -9)
📝 components/mods-data.ts (+5 -3)

📄 Description

🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself.

Xmilon: "commits on the site don't update". This PR only changes how data is refreshed. Nothing visible changes: no markup or styles are touched.

Why it lagged

  • Each GitHub loader is cached for 15 min (cacheLife), docs and contributors for hours.
  • raw.githubusercontent.com keeps a branch's files for another 5 min.
  • The Railway service has no GITHUB_TOKEN, so reads are anonymous (60 an hour for its address).

What

  • Cache tags on every GitHub loader (components/github-fresh.ts): github:horizon:main, github:horizon:issues, github:horizon:releases, github:horizon-mods:main.
  • POST /api/revalidate: bearer REVALIDATE_SECRET, body {"tags": [...]} (allowlisted). It calls revalidateTag(tag, { expire: 0 }). Kira calls it from GitHub's webhook, then loads the pages once. Without the secret, the route is a 404.
  • Files of main read at main's current commit (rawMainUrl): roadmap.json, docs/api, README, MOD-POLICY. This avoids raw's 5-minute cache.
  • REST reads through Kira (components/github-api.ts, GITHUB_PROXY_URL): Kira's GitHub App and its ETag cache. If Kira doesn't answer, reads go straight to api.github.com.
  • Without Kira's calls, every loader keeps its own cacheLife, as before. The only difference is that docs now revalidate every 15 min instead of every hour, because they follow main's commit.

Kira side: horizon-rust/kira#107 (merged, live).

Tests

  • npm run lint, npm run build: OK.
  • Locally with npm start:
    • /api/revalidate answers 401 with a wrong secret and 400 with unknown tags. With the right secret, the tagged pages go from x-nextjs-cache: HIT to MISS (regenerated), then back to HIT.
    • A build and run with no GitHub token, reading through Kira's live proxy, serves /releases, /hub and /data/journal.json with no errors.

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/horizon-rust/horizon-site/pull/34 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 11/1/2026 **Status:** ✅ Merged **Merged:** 11/1/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `feat/revalidate-on-push` --- ### 📝 Commits (2) - [`57cb79b`](https://github.com/horizon-rust/horizon-site/commit/57cb79bca4372b18d28308e375c2856a579da4ee) Revalidate GitHub data on Kira's call: fresh within a minute of a push - [`3314bf9`](https://github.com/horizon-rust/horizon-site/commit/3314bf9cbb43a5c5432133fc36919fd305b3c167) Read GitHub's REST API through Kira's proxy, straight from GitHub as a fallback ### 📊 Changes **11 files changed** (+153 additions, -34 deletions) <details> <summary>View changed files</summary> 📝 `CLAUDE.md` (+1 -1) 📝 `README.md` (+10 -0) ➕ `app/api/revalidate/route.ts` (+33 -0) 📝 `components/contributors.tsx` (+5 -5) 📝 `components/docs-data.ts` (+4 -2) ➕ `components/github-api.ts` (+30 -0) ➕ `components/github-fresh.ts` (+38 -0) 📝 `components/github-releases.ts` (+5 -5) 📝 `components/hub-data.ts` (+9 -9) 📝 `components/journal-feed.ts` (+13 -9) 📝 `components/mods-data.ts` (+5 -3) </details> ### 📄 Description > 🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself. Xmilon: "commits on the site don't update". This PR only changes how data is refreshed. **Nothing visible changes**: no markup or styles are touched. ## Why it lagged - Each GitHub loader is cached for 15 min (`cacheLife`), docs and contributors for hours. - `raw.githubusercontent.com` keeps a branch's files for another 5 min. - The Railway service has **no `GITHUB_TOKEN`**, so reads are anonymous (60 an hour for its address). ## What - **Cache tags** on every GitHub loader (`components/github-fresh.ts`): `github:horizon:main`, `github:horizon:issues`, `github:horizon:releases`, `github:horizon-mods:main`. - **`POST /api/revalidate`**: bearer `REVALIDATE_SECRET`, body `{"tags": [...]}` (allowlisted). It calls `revalidateTag(tag, { expire: 0 })`. Kira calls it from GitHub's webhook, then loads the pages once. Without the secret, the route is a 404. - **Files of main read at main's current commit** (`rawMainUrl`): roadmap.json, docs/api, README, MOD-POLICY. This avoids raw's 5-minute cache. - **REST reads through Kira** (`components/github-api.ts`, `GITHUB_PROXY_URL`): Kira's GitHub App and its ETag cache. If Kira doesn't answer, reads go straight to api.github.com. - Without Kira's calls, every loader keeps its own `cacheLife`, as before. The only difference is that docs now revalidate every 15 min instead of every hour, because they follow main's commit. Kira side: horizon-rust/kira#107 (merged, live). ## Tests - `npm run lint`, `npm run build`: OK. - Locally with `npm start`: - `/api/revalidate` answers 401 with a wrong secret and 400 with unknown tags. With the right secret, the tagged pages go from `x-nextjs-cache: HIT` to `MISS` (regenerated), then back to `HIT`. - A build and run with **no GitHub token**, reading through Kira's live proxy, serves /releases, /hub and /data/journal.json with no errors. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 04:02:33 +07:00
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
horizon-rust/horizon-site#36
No description provided.