mirror of
https://github.com/LucasKalil-Programador/world-2026-hub.git
synced 2026-07-04 17:41:28 -03:00
feat(cache): add cache-busting version for data files
This commit is contained in:
parent
6d835b43b9
commit
da8a8838c6
3 changed files with 17 additions and 2 deletions
|
|
@ -242,6 +242,10 @@ Follow `how-refresh-data.md` (project root). In short:
|
||||||
- **Sync incremental:** a action mantém `.ftp-deploy-sync-state.json` no servidor; só reenvia arquivos alterados. Não comitar esse arquivo (vive só no servidor).
|
- **Sync incremental:** a action mantém `.ftp-deploy-sync-state.json` no servidor; só reenvia arquivos alterados. Não comitar esse arquivo (vive só no servidor).
|
||||||
- **Gotcha:** se a Hostinger não aceitar FTPS explícito, trocar `protocol` para `ftp`. Se o site ficar em subpasta, lembrar do gotcha #7 (paths relativos) — já está OK no projeto.
|
- **Gotcha:** se a Hostinger não aceitar FTPS explícito, trocar `protocol` para `ftp`. Se o site ficar em subpasta, lembrar do gotcha #7 (paths relativos) — já está OK no projeto.
|
||||||
|
|
||||||
|
### Data cache-busting via DATA_VERSION (2026-06-14)
|
||||||
|
- **`assets/js/app.js` `loadData()` appends `?v=${DATA_VERSION}`** to every `data/*.json` fetch (`DATA_VERSION` constant near the top of the file, currently `'2026-06-13-rev1'`). Fixes production browsers/Hostinger caching stale `results.json` after a daily refresh — `cache: 'reload'` only helps the developer's own browser, not real visitors.
|
||||||
|
- **Must be bumped on every data refresh** — added as step 4 of the daily routine in `how-refresh-data.md`. Format `YYYY-MM-DD-revN`; increment `revN` for same-day re-edits.
|
||||||
|
|
||||||
### How to add a UI label
|
### How to add a UI label
|
||||||
1. Add the key to both `en` and `pt` dicts in `assets/js/i18n.js`.
|
1. Add the key to both `en` and `pt` dicts in `assets/js/i18n.js`.
|
||||||
2. Use `t("key")` at the render site — never hardcode the string.
|
2. Use `t("key")` at the render site — never hardcode the string.
|
||||||
|
|
|
||||||
|
|
@ -14,12 +14,14 @@ import { initBracket } from './bracket.js';
|
||||||
|
|
||||||
let data = null;
|
let data = null;
|
||||||
|
|
||||||
|
const DATA_VERSION = '2026-06-13-rev1';
|
||||||
|
|
||||||
export async function loadData() {
|
export async function loadData() {
|
||||||
if (data) return data;
|
if (data) return data;
|
||||||
const files = ['teams', 'groups', 'matches', 'results', 'stadiums', 'bracket-config'];
|
const files = ['teams', 'groups', 'matches', 'results', 'stadiums', 'bracket-config'];
|
||||||
const [teams, groups, matches, results, stadiums, bracketConfig] = await Promise.all(
|
const [teams, groups, matches, results, stadiums, bracketConfig] = await Promise.all(
|
||||||
files.map(async (name) => {
|
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}`);
|
if (!res.ok) throw new Error(`data/${name}.json — HTTP ${res.status}`);
|
||||||
return res.json();
|
return res.json();
|
||||||
}),
|
}),
|
||||||
|
|
|
||||||
|
|
@ -65,6 +65,14 @@ Rules:
|
||||||
> ⚠️ First pending item: **match id 4 (USA vs Paraguay)** kicked off 2026-06-13
|
> ⚠️ First pending item: **match id 4 (USA vs Paraguay)** kicked off 2026-06-13
|
||||||
> 01:00 UTC and is still `scheduled` in the data.
|
> 01:00 UTC and is still `scheduled` in the data.
|
||||||
|
|
||||||
|
### 4. Bump the cache-busting version
|
||||||
|
|
||||||
|
Any time `data/*.json` changes, update `DATA_VERSION` in `assets/js/app.js`
|
||||||
|
(top of `loadData()`) to today's date, e.g. `'2026-06-14-rev1'`. This is
|
||||||
|
appended as `?v=...` to every data fetch — without bumping it, visitors on
|
||||||
|
Hostinger may keep getting yesterday's cached `results.json`. If you edit
|
||||||
|
data more than once in the same day, increment the `revN` suffix.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## One-time: `thirdPlaceAssignment` (after ~Jun 27–28)
|
## One-time: `thirdPlaceAssignment` (after ~Jun 27–28)
|
||||||
|
|
@ -130,4 +138,5 @@ single-source (Wikipedia 17:00 PDT vs one ESPN summary implying 14:00 PDT).
|
||||||
|
|
||||||
Per project convention, append a short dated line to `.agents/project-memory.md`
|
Per project convention, append a short dated line to `.agents/project-memory.md`
|
||||||
("results updated through match id N on YYYY-MM-DD") and tick anything completed
|
("results updated through match id N on YYYY-MM-DD") and tick anything completed
|
||||||
in `.agents/TODO.md` §6.
|
in `.agents/TODO.md` §6. Confirm `DATA_VERSION` in `assets/js/app.js` was bumped
|
||||||
|
to today's date (step 4 above) before committing.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue