feat(cache): add cache-busting version for data files

This commit is contained in:
Lucas Kalil 2026-06-14 00:06:37 -03:00
parent 6d835b43b9
commit da8a8838c6
3 changed files with 17 additions and 2 deletions

View file

@ -14,12 +14,14 @@ import { initBracket } from './bracket.js';
let data = null;
const DATA_VERSION = '2026-06-13-rev1';
export async function loadData() {
if (data) return data;
const files = ['teams', 'groups', 'matches', 'results', 'stadiums', 'bracket-config'];
const [teams, groups, matches, results, stadiums, bracketConfig] = await Promise.all(
files.map(async (name) => {
const res = await fetch(`data/${name}.json`);
const res = await fetch(`data/${name}.json?v=${DATA_VERSION}`);
if (!res.ok) throw new Error(`data/${name}.json — HTTP ${res.status}`);
return res.json();
}),