Cache 가 CI 의 가장 큰 단일 가속
처음 deps 설치 — 분 단위. 두 번째, warm cache — 초 단위. actions/cache 가 범용 primitive; setup-* action 은 내장 cache 단축 가짐.
Cache 두 방식
1) Built-in cache (권장)
actions/setup-python@v5+cache: pip.actions/setup-node@v4+cache: npm/pnpm/yarn.astral-sh/setup-uv@v3+enable-cache: true.actions/setup-go@v5는 기본적으로 Go module cache.
2) 범용 actions/cache
path:— cache 할 거.key:— 주 키. 보통${{ runner.os }}-deps-${{ hashFiles('**/lockfile') }}.restore-keys:— 정확한 key 없으면 prefix 폴백.
Cache 함정
- Cache 는 branch 범위. main 의 cache 는 다른 branch 에서도 보임 — 하지만 feature branch cache 는 main 에서 안 보임.
- Repo 당 총 10GB cache. 오래된 cache 는 LRU 로 제거.
- Build 출력 caching (
dist/,.next/) 은 시간 절약하지만 정확성 위험 있음. 가끔 cold cache 로 build 가 여전히 작동하는지 검증.