diff --git a/site/src/components/Header.astro b/site/src/components/Header.astro index 0c657d9..436b7cf 100644 --- a/site/src/components/Header.astro +++ b/site/src/components/Header.astro @@ -173,15 +173,16 @@ const starsLabel = stars >= 1000 ? `${(stars / 1000).toFixed(1)}k` : String(star } const cached = sessionStorage.getItem(CACHE_KEY); + let isFresh = false; if (cached) { const { value, ts } = JSON.parse(cached); if (Date.now() - ts < CACHE_TTL) { starsEl.textContent = formatStars(value); - return; // cache is fresh, skip API call + isFresh = true; } } - fetch('https://api.github.com/repos/samber/awesome-prometheus-alerts', { + if (!isFresh) fetch('https://api.github.com/repos/samber/awesome-prometheus-alerts', { headers: { Accept: 'application/vnd.github+json' }, }) .then((r) => r.ok ? r.json() : null) diff --git a/site/src/components/StatsBar.astro b/site/src/components/StatsBar.astro index eef3c02..9867d98 100644 --- a/site/src/components/StatsBar.astro +++ b/site/src/components/StatsBar.astro @@ -55,15 +55,16 @@ const starsLabel = stars >= 1000 ? `${(stars / 1000).toFixed(1)}k` : String(star } const cached = sessionStorage.getItem(CACHE_KEY); + let isFresh = false; if (cached) { const { value, ts } = JSON.parse(cached); if (Date.now() - ts < CACHE_TTL) { starsEl.textContent = fmt(value); - return; // cache is fresh, skip API call + isFresh = true; } } - fetch('https://api.github.com/repos/samber/awesome-prometheus-alerts', { + if (!isFresh) fetch('https://api.github.com/repos/samber/awesome-prometheus-alerts', { headers: { Accept: 'application/vnd.github+json' }, }) .then((r) => r.ok ? r.json() : null)