Visitar URL original
feat(web): version data URLs per build by allen0099 · Pull Request #26 · Ti-wb/bus-analysis · GitHub
Skip to content

feat(web): version data URLs per build - #26

Merged
allen0099 merged 1 commit into
mainfrom
feat/versioned-web-data
Oct 24, 2026
Merged

allen0099 merged 1 commit into
mainfrom
feat/versioned-web-data

Conversation

@allen0099

Copy link
Copy Markdown
Collaborator

問題

GitHub Pages 對所有檔案固定回傳 Cache-Control: max-age=600。程式檔名每次建置都會改變,但 data/ 下的檔名固定。部署後 10 分鐘內,瀏覽器可能用新程式讀到前一版的快取資料。例如 #19 部署後,站位資料還是舊的、缺少 route_ids,點公車站就只會顯示 350 m 周邊。

變更

  • 前端讀取 data/ 時一律在網址加上建置版本 ?v=…。
    • CI:GITHUB_SHA 前 12 碼。
    • 本機 npm run build:建置時間。
    • npm run dev:不加。
  • 版本號由 vite.config.ts 寫入。data.ts 新增 dataURL(),改善清單與路線工具也改用它。
  • 年齡資料會先試 .gz,所以版本號加在實際送出的請求上,網址是 ….json.gz?v=…。
  • docs/web-map.md 新增〈快取與 Cloudflare〉,說明在 Cloudflare 後台要加的 Cache Rules,以及設定後如何驗證。

驗證

  • npm --prefix web run build 通過。用假的 GITHUB_SHA 建置後,產出的程式帶有該 commit 值。
  • test:routes、test:improvements、test:age、test:focus、test:map、test:regional 全數通過。
  • 用 vite preview 依序操作首頁、點公車站、改善清單、路線工具,送出的 20 個 data/ 請求全部帶同一個版本號,主控台沒有錯誤。

合併後

Cloudflare 規則需要在後台手動設定,步驟見 docs/web-map.md。不設也能運作,只是 Cloudflare 會繼續只轉送、不快取。

@coderabbitai

coderabbitai Bot commented Oct 24, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 09db1a3e-a6ff-4b9e-9c05-67c0843363a9
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@allen0099
allen0099 merged commit aee903b into main Oct 24, 2026
2 checks passed
@allen0099
allen0099 deleted the feat/versioned-web-data branch October 24, 2026 16:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant