Web image serves index.html without Cache-Control and answers missing assets with index.html, so the app loads blank after an upgrade
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 79/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- docker, typescript
調査の方向性
まず apps/web/Caddyfile と issue の再現手順を確認します。これらには、検証するキャッシュヘッダーとアセット欠落時の挙動が示されています。docker compose up -d web caddy で web イメージをビルドして実行し、続いて / と存在しない /assets/ パスに対して、記載されている curl -I の確認を行います。アプリのエントリーポイントが再検証され、存在しないアセットが 404 を返せば完了です。提案された設定を実装する場合は、ハッシュ付きアセットが長期間の immutable キャッシュを維持することも確認してください。
索引モデルが issue の本文から書いたものです。
説明
After an upgrade, the web app can load a blank page for returning users. The web image's Caddy serves index.html with Last-Modified and ETag but no Cache-Control. Browsers therefore cache it heuristically: RFC 9111 §4.2.2 allows a response to be treated as fresh for a fraction of its age, typically 10% of the time since Last-Modified. index.html is rewritten by import-meta-env when the container starts, so a web container that has been running for 30 days hands out an index.html that browsers may reuse for about 3 days without asking the server. Once a new image is deployed, a user who opens the app from a bookmark gets the old cached index.html. Its <script type="module" src="/assets/index-<old hash>.js"> no longer exists in the new image. try_files {path} /index.html then answers that request with 200 text/html, the browser refuses to run HTML as a module, and the page stays blank until the heuristic expires or the user force-reloads. The same fallback breaks any tab left open across an upgrade. Route chunks are code-split (autoCodeSplitting: true), so the next navigation imports an old chunk and gets HTML back instead of a 404. #936 tracks the same caching problem for the playground image. This issue is the clinician-facing web image.
Where
apps/web/Caddyfile:1-6:
:80 {
root * /srv
encode gzip zstd
try_files {path} /index.html
file_server
}
apps/web/Dockerfile:30 rewrites index.html at every container start:
CMD [ "sh", "-c", "import-meta-env -x .env.public -p index.html && caddy run --config /etc/caddy/Caddyfile --adapter caddyfile" ]
Reproduce
- Run
caddy:2.7-alpinewithapps/web/Caddyfileover a/srvcontainingindex.htmlandassets/index-NEW.js. - Run
curl -I /andcurl -I /assets/index-OLD.js.
Actual (verified locally): / returns 200 with Last-Modified and ETag and no Cache-Control. /assets/index-OLD.js, which does not exist, returns 200 Content-Type: text/html with the body of index.html.
Expected: index.html is sent with Cache-Control: no-cache, so every navigation revalidates it, and a missing /assets/* file returns 404.
Tests
No unit or Playwright test runs the production Caddy image. The e2e suite drives the Vite dev server. Verify the fix with the curl checks above against the built image, using docker compose up -d web caddy and curl -I http://localhost:$APP_PORT/ and /assets/does-not-exist.js.
Suggested fix
In apps/web/Caddyfile, give /assets/* its own handle with file_server and no try_files fallback, and set header Cache-Control "public, max-age=31536000, immutable" there, since those files are content-hashed. In the SPA fallback handle, set header Cache-Control "no-cache" so index.html is always revalidated. With the 404 in place, apps/web can also listen for Vite's vite:preloadError and reload, which covers tabs left open across an upgrade.
- 主要言語
- TypeScript
- スター
- 119
- フォーク
- 19
- 平均マージ
- 1日 2時間
- マージ済み PR(30日)
- 56
環境構築
- Dockerfile または Docker Compose ファイルあり
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
DouglasNeuroInformatics/OpenDataCapture のほかの issue
-
Area: Playground Bug Difficulty: Low Good First Issue Priority: Low
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
DouglasNeuroInformatics/OpenDataCapture#1805 ·
メンテナーはふだん 1 日以内に返信
-
Area: Instruments Bug Difficulty: Low Priority: Low
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
DouglasNeuroInformatics/OpenDataCapture#1801 ·
メンテナーはふだん 1 日以内に返信
-
Area: Instruments Bug Difficulty: Low Good First Issue Priority: Low
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
DouglasNeuroInformatics/OpenDataCapture#1800 ·
メンテナーはふだん 1 日以内に返信
-
Area: Instruments Bug Difficulty: Low Good First Issue Priority: Low
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
DouglasNeuroInformatics/OpenDataCapture#1799 ·
メンテナーはふだん 1 日以内に返信
-
Area: Instruments Bug Difficulty: Low Performance Priority: Medium
難易度 2/5 1〜3時間 初心者へのやさしさ 83/100
DouglasNeuroInformatics/OpenDataCapture#1795 ·
メンテナーはふだん 1 日以内に返信
DouglasNeuroInformatics/OpenDataCapture の issue をすべて見る
似ている issue
-
難易度 1/5 1時間未満 初心者へのやさしさ 85/100
MystenLabs/MemWal#1163 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
Mondriaan
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
knaw-huc/textannoviz#709 ·
メンテナーはふだん 1 日以内に返信
-
billion-context-pi
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
ranxianglei/billion-context#2521 · コメント 3 件 ·
メンテナーはふだん 1 日以内に返信
-
Add: YRF Music Nepalオープンstreams:add
難易度 1/5 1時間未満 初心者へのやさしさ 62/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100