fix(website): query GitHub API first for stars widget to avoid stale counts#229
Merged
Merged
Conversation
…counts The stars/forks widget queried ungh.cc first — a CDN-cached proxy that lags GitHub by ~a day — and only fell back to the authoritative GitHub API. Combined with the 1-hour localStorage cache, this surfaced stale counts whenever the star total was moving. Flip the priority: query api.github.com first (per-visitor 60/hour unauthenticated limit is ample for one cached request/hour), with ungh.cc as the resilience fallback for busy/shared IPs. Add response shape validation so a malformed GitHub payload falls through instead of painting NaN. Applied to both the docs and marketing-site copies. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The GitHub stars/forks widget on the docs and marketing sites was showing stale (old) counts.
The widget queried ungh.cc first — a CDN-cached GitHub proxy that lags the real count by ~a day — falling back to the authoritative GitHub API only if ungh failed. The 1-hour localStorage cache then pinned that stale value per visitor. The original rationale (avoiding GitHub's 60-req/hour limit) doesn't really apply to a client-side fetch: each visitor spends their own IP's budget on one cached request per hour.
When checked live, both sources happened to agree (134★/19⑂), which is why the staleness was intermittent — it only showed while the count was moving.
Fix
NaN.docs/javascripts/main.jsandwebsite/script.js.The 1-hour localStorage cache is unchanged — it's reasonable and now caches a fresh value.
Notes
README.mdshields.io social badge is a separate, independently-cached path and was left untouched.🤖 Generated with Claude Code