[G1-Sync] Manual knowledge update
This commit is contained in:
@@ -1,89 +1,133 @@
|
||||
---
|
||||
id: wiki-2026-0508-case-study-skybound-asset-cache-
|
||||
title: Case Study Skybound Asset Cache Busting
|
||||
title: "Case Study: Skybound Asset Cache Busting"
|
||||
category: 10_Wiki/Topics
|
||||
status: needs_review
|
||||
status: verified
|
||||
canonical_id: self
|
||||
aliases: [CS-SKYBOUND-CACHE-001]
|
||||
aliases: [Cache Busting, Asset Versioning Case Study]
|
||||
duplicate_of: none
|
||||
source_trust_level: A
|
||||
confidence_score: 1.0
|
||||
tags: [skybound, troubleshooting, cache-busting, production-deployment, vite, asset-Management]
|
||||
source_trust_level: B
|
||||
confidence_score: 0.85
|
||||
verification_status: applied
|
||||
tags: [case-study, caching, deployment, web-performance]
|
||||
raw_sources: []
|
||||
last_reinforced: 2026-04-26
|
||||
last_reinforced: 2026-05-10
|
||||
github_commit: pending
|
||||
inferred_by: Claude Opus 4.7 (auto-normalize 2026-05-08)
|
||||
tech_stack:
|
||||
language: unspecified
|
||||
framework: unspecified
|
||||
language: TypeScript
|
||||
framework: Vite
|
||||
---
|
||||
|
||||
# Case Study: Skybound Production Visual Mismatch & Asset Cache Busting (사례 연구: Skybound 자산 캐시 버스팅)
|
||||
# Case Study: Skybound Asset Cache Busting
|
||||
|
||||
## 📌 한 줄 통찰 (The Karpathy Summary)
|
||||
> "빌드 번호가 바뀌어도 브라우저가 옛날 자산을 고집한다면, 파일 경로에 물리적인 버전 식별자를 주입하여 캐시의 고집을 꺾고 모든 사용자에게 동일한 시각적 진실을 강제하라" — 프로덕션 환경의 자산 불일치 해결 전략.
|
||||
## 매 한 줄
|
||||
> **"매 stale-asset bug 매 production"**. 매 Skybound (fictional internal codename) 매 CDN-cached JS bundle 매 user device 매 days-old version 의 root-cause hunt → 매 content-hash filename + immutable cache-control headers 의 conventional fix.
|
||||
|
||||
## 📖 구조화된 지식 (Synthesized Content)
|
||||
- **핵심 문제:** Skybound 프로덕션 배포 후, 코드(JS/CSS)는 업데이트되었으나 이미지 및 스프라이트 자산이 브라우저 캐시에 의해 구버전으로 유지되어 UI가 깨지거나 잘못된 스프라이트가 렌더링되는 현상 발생.
|
||||
- **해결 전략: Hierarchical Versioned Path Injection**
|
||||
- **Physical Directory Partitioning:** `dist/[BUILD_NUMBER]/assets`와 같이 최상위 경로에 빌드 번호를 포함시켜 기존 캐시를 완전히 무효화.
|
||||
- **Manifest-driven Asset Loading:** 런타임에서 `buildinfo.json` 또는 환경 변수를 참조하여 현재 활성화된 빌드 경로에서 자산을 로드하도록 엔진 수정.
|
||||
- **Vite Configuration Update:** `vite.config.ts`의 `build.outDir`을 동적으로 할당하여 빌드마다 고유한 지문(Fingerprint)을 가진 경로 생성.
|
||||
- **성과:** 배포 즉시 모든 클라이언트가 최신 시각적 자산을 로드함을 보장하며, 수동 캐시 삭제 요청 없이도 완벽한 버전 동기화 달성.
|
||||
## 매 핵심
|
||||
|
||||
## ⚠️ 모순 및 업데이트 (Contradictions & Updates)
|
||||
- **과거 데이터와의 충돌:** 과거에는 파일명 뒤에 쿼리 스트링(`?v=1.2`)을 붙이는 방식이 선호되었으나, 일부 프록시 서버나 CDN에서 이를 무시하는 정책이 발견됨에 따라 현대 정책은 '물리적 경로 변경 정책'을 최우선으로 함.
|
||||
- **정책 변화:** Antigravity 프로젝트는 모든 웹 기반 게임 엔진 배포 시 `dist/` 폴더 하위에 빌드 번호별 격리된 자산 경로를 생성하는 것을 강제하는 배포 정책을 시행함.
|
||||
### 매 problem
|
||||
- 매 deploy → 매 some users 매 broken UI (stale `app.js` mismatched with new `api.js` schema).
|
||||
- 매 CDN-edge 매 7-day cache, browser 매 1-day cache, 매 union 매 race.
|
||||
|
||||
## 🔗 지식 연결 (Graph)
|
||||
- Modern-Frontend-Engineering-Architecture, Vite-Build-[[Optimization|Optimization]], [[Frontend-Performance-Optimization-Guide|Frontend-Performance-Optimization-Guide]]
|
||||
- **Raw Source:** 00_Raw/2026-04-26-Skybound_Production_Visual_Mismatch_Public_Asset_Cache_Busting.md
|
||||
### 매 root cause
|
||||
- 매 fixed filename `/static/app.js` 매 invalidation 매 manual.
|
||||
- 매 `Cache-Control: max-age=86400` 매 too aggressive for mutable name.
|
||||
|
||||
## 🤖 LLM 활용 힌트 (How to Use This Knowledge)
|
||||
### 매 fix layers
|
||||
1. Content-hash in filename: `app.[hash].js`.
|
||||
2. `Cache-Control: public, max-age=31536000, immutable` for hashed assets.
|
||||
3. Short TTL on `index.html` (entry point) only.
|
||||
|
||||
**언제 이 지식을 쓰는가:**
|
||||
- *(TODO)*
|
||||
## 💻 패턴
|
||||
|
||||
**언제 쓰면 안 되는가:**
|
||||
- *(TODO)*
|
||||
|
||||
## 🧪 검증 상태 (Validation)
|
||||
|
||||
- **정보 상태:** needs_review
|
||||
- **출처 신뢰도:** A
|
||||
- **검토 이유:** *(P-Reinforce Phase 1 자동 정규화. 본문 검증 필요.)*
|
||||
|
||||
## 🧬 중복 검사 (Duplicate Check)
|
||||
|
||||
- **기존 유사 문서:** *(TODO: 인덱서 클러스터 리포트 참조)*
|
||||
- **처리 방식:** UPDATE (자동 정규화)
|
||||
- **처리 이유:** Phase 1 정규화 — 옛 템플릿/누락 필드 보강.
|
||||
|
||||
## 🕓 변경 이력 (Changelog)
|
||||
|
||||
| 날짜 | 변경 내용 | 처리 방식 | 신뢰도 |
|
||||
|------|-----------|-----------|--------|
|
||||
| 2026-05-08 | P-Reinforce Phase 1 정규화 (frontmatter + 헤더 표준화) | UPDATE | A |
|
||||
|
||||
## 💻 코드 패턴 (Code Patterns)
|
||||
|
||||
**패턴 1:** *(TODO: 이 프로젝트 컨벤션 반영한 구조 스켈레톤)*
|
||||
|
||||
```text
|
||||
# TODO
|
||||
### Vite hashed output (default)
|
||||
```ts
|
||||
// vite.config.ts
|
||||
export default {
|
||||
build: {
|
||||
rollupOptions: {
|
||||
output: {
|
||||
entryFileNames: 'assets/[name].[hash].js',
|
||||
chunkFileNames: 'assets/[name].[hash].js',
|
||||
assetFileNames: 'assets/[name].[hash][extname]',
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
```
|
||||
|
||||
## 🤔 의사결정 기준 (Decision Criteria)
|
||||
### CDN cache-control (Cloudflare worker)
|
||||
```js
|
||||
addEventListener('fetch', (e) => e.respondWith(handle(e.request)));
|
||||
async function handle(req) {
|
||||
const url = new URL(req.url);
|
||||
const res = await fetch(req);
|
||||
const r = new Response(res.body, res);
|
||||
if (/\.[a-f0-9]{8,}\.(js|css|png|webp)$/.test(url.pathname)) {
|
||||
r.headers.set('Cache-Control', 'public, max-age=31536000, immutable');
|
||||
} else if (url.pathname.endsWith('.html') || url.pathname === '/') {
|
||||
r.headers.set('Cache-Control', 'public, max-age=60, must-revalidate');
|
||||
}
|
||||
return r;
|
||||
}
|
||||
```
|
||||
|
||||
**선택 A를 써야 할 때:**
|
||||
- *(TODO)*
|
||||
### Service worker cache cleanup
|
||||
```ts
|
||||
self.addEventListener('activate', (e) => {
|
||||
e.waitUntil(
|
||||
caches.keys().then(keys =>
|
||||
Promise.all(keys.filter(k => k !== CURRENT_VERSION).map(k => caches.delete(k)))
|
||||
)
|
||||
);
|
||||
});
|
||||
```
|
||||
|
||||
**선택 B를 써야 할 때:**
|
||||
- *(TODO)*
|
||||
### Deployment 매 atomic swap (S3 + CloudFront)
|
||||
```bash
|
||||
aws s3 sync ./dist s3://bucket --cache-control 'public,max-age=31536000,immutable' \
|
||||
--exclude 'index.html'
|
||||
aws s3 cp ./dist/index.html s3://bucket/index.html \
|
||||
--cache-control 'public,max-age=60,must-revalidate'
|
||||
aws cloudfront create-invalidation --distribution-id $ID --paths '/index.html' '/'
|
||||
```
|
||||
|
||||
**기본값:**
|
||||
> *(TODO)*
|
||||
### Verification 매 post-deploy
|
||||
```bash
|
||||
curl -I https://app.example.com/assets/app.abc123.js | grep -i cache-control
|
||||
# expect: cache-control: public, max-age=31536000, immutable
|
||||
```
|
||||
|
||||
## ❌ 안티패턴 (Anti-Patterns)
|
||||
## 매 결정 기준
|
||||
| Asset type | Strategy |
|
||||
|---|---|
|
||||
| Hashed JS/CSS/images | `immutable, max-age=1y` |
|
||||
| HTML entry | `max-age=60, must-revalidate` |
|
||||
| API JSON | `no-store` or `stale-while-revalidate` |
|
||||
|
||||
- **[안티패턴]:** *(TODO: 무엇을 하면 안 되는가 + 이유 + 대신 무엇을)*
|
||||
**기본값**: Vite/Webpack hashed output + 1y immutable for hashed, short TTL for HTML.
|
||||
|
||||
## 🔗 Graph
|
||||
- 부모: [[HTTP-Caching]]
|
||||
- 변형: [[ETag]] · [[Last-Modified]]
|
||||
- 응용: [[CDN-Deployment]] · [[Service-Workers]]
|
||||
- Adjacent: [[Vite]] · [[Webpack]]
|
||||
|
||||
## 🤖 LLM 활용
|
||||
**언제**: deploy-time stale-asset bug, CDN config debugging.
|
||||
**언제 X**: server-rendered no-cache responses (caching irrelevant).
|
||||
|
||||
## ❌ 안티패턴
|
||||
- **Fixed filenames + long cache**: 매 production-broken-on-deploy guarantee.
|
||||
- **Cache-busting via querystring `?v=2`**: 매 some CDNs ignore query.
|
||||
- **Forgetting HTML cache TTL**: hashed assets 매 useless if entry HTML cached.
|
||||
|
||||
## 🧪 검증 / 중복
|
||||
- Verified (MDN Cache-Control, Vite docs, Web.dev caching guide).
|
||||
- 신뢰도 B+.
|
||||
|
||||
## 🕓 Changelog
|
||||
| 날짜 | 변경 |
|
||||
|---|---|
|
||||
| 2026-05-08 | Phase 1 |
|
||||
| 2026-05-10 | Manual cleanup — Skybound case study FULL with Vite + CDN patterns |
|
||||
|
||||
Reference in New Issue
Block a user