From f45be09ff1c918cca42986dd504763bc38e2a665 Mon Sep 17 00:00:00 2001 From: ByungCheol Date: Wed, 3 Jun 2026 18:11:51 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=EB=B0=B0=ED=8F=AC=20=ED=9B=84=20?= =?UTF-8?q?=EC=B2=AD=ED=81=AC=20=EB=A1=9C=EB=93=9C=20=EC=8B=A4=ED=8C=A8=20?= =?UTF-8?q?=EC=8B=9C=20=EC=9E=90=EB=8F=99=20=EC=83=88=EB=A1=9C=EA=B3=A0?= =?UTF-8?q?=EC=B9=A8=20+=20index.html=20no-cache?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 모바일 웹에서 옛 index.html 캐시가 삭제된 옛 청크를 불러 메뉴(가계부 내역 등)가 안 열리는 문제 → router.onError 로 청크 실패 감지 시 목적지로 전체 새로고침 - nginx 설정에 index.html no-cache 추가(재발 방지) — 서버 적용 필요 Co-Authored-By: Claude Opus 4.8 --- deploy/nginx-sb-front.conf | 9 ++++++++- src/router/index.js | 12 ++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/deploy/nginx-sb-front.conf b/deploy/nginx-sb-front.conf index bf7a6a1..7329130 100644 --- a/deploy/nginx-sb-front.conf +++ b/deploy/nginx-sb-front.conf @@ -11,7 +11,14 @@ server { try_files $uri $uri/ /index.html; } - # 해시 자산 장기 캐시 + # index.html 은 캐시 금지 — 배포로 청크 해시가 바뀌어도 항상 최신 진입점을 받도록. + # (캐시되면 옛 index.html 이 삭제된 옛 청크를 불러 메뉴가 안 열리는 문제 발생) + location = /index.html { + add_header Cache-Control "no-cache, no-store, must-revalidate"; + expires -1; + } + + # 해시 자산 장기 캐시 (파일명에 해시가 있어 immutable 안전) location /assets/ { expires 1y; add_header Cache-Control "public, immutable"; diff --git a/src/router/index.js b/src/router/index.js index d77ca18..d0ac091 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -107,4 +107,16 @@ router.beforeEach((to, from) => { } }) +// 새 배포로 청크 해시가 바뀐 뒤, 캐시된 옛 index.html 이 삭제된 옛 청크를 부르면 +// 동적 import 가 실패한다. 이 경우 목적지로 전체 새로고침해 최신 index.html 을 받게 한다. +let reloadingForChunk = false +router.onError((err, to) => { + const msg = (err && err.message) || '' + const chunkError = /dynamically imported module|Importing a module script failed|Failed to fetch dynamically imported module|ChunkLoadError|error loading dynamically imported module/i.test(msg) + if (chunkError && !reloadingForChunk) { + reloadingForChunk = true + window.location.assign(to?.fullPath || window.location.pathname) + } +}) + export default router