Skip to content

Commit 636edbf

Browse files
psmonclaude
andcommitted
fix(harness-view): cache-bust loader fetches so reload always picks up redeploys
GitHub Pages + browser caches were serving stale indexes/*.json and data/*.json after a `doc-v*` redeploy — users had to do a hard reload (Ctrl+F5) to see the new build. loader.js now appends a per-page-load `?_t=<timestamp>` query to every fetch, so a normal reload always pulls fresh content while in-session duplicate calls still hit cache. Applies to fetchText / fetchJson, which loadIndex / loadData / loadMd all flow through. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 0bd233b commit 636edbf

1 file changed

Lines changed: 17 additions & 3 deletions

File tree

Home/harness-view/js/utils/loader.js

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,27 @@
1-
/** fetch 래퍼 - 텍스트/JSON 로드와 에러 처리 */
1+
/** fetch 래퍼 - 텍스트/JSON 로드와 에러 처리.
2+
*
3+
* Cache-busting: GitHub Pages serves static files with long cache headers, and
4+
* reverse proxies / browser caches frequently keep stale `indexes/*.json` and
5+
* `data/*.json` after a `doc-v*` redeploy. We append a per-page-load timestamp
6+
* to every fetch URL so reload always pulls fresh content; inside the same
7+
* session the timestamp stays constant so duplicate calls still hit cache.
8+
*/
9+
10+
const PAGE_LOAD_ID = Date.now();
11+
12+
function withBust(url) {
13+
const sep = url.includes('?') ? '&' : '?';
14+
return `${url}${sep}_t=${PAGE_LOAD_ID}`;
15+
}
216

317
export async function fetchText(url) {
4-
const res = await fetch(url);
18+
const res = await fetch(withBust(url));
519
if (!res.ok) throw new Error(`fetch ${url} -> ${res.status}`);
620
return await res.text();
721
}
822

923
export async function fetchJson(url) {
10-
const res = await fetch(url);
24+
const res = await fetch(withBust(url));
1125
if (!res.ok) throw new Error(`fetch ${url} -> ${res.status}`);
1226
return await res.json();
1327
}

0 commit comments

Comments
 (0)