-
Notifications
You must be signed in to change notification settings - Fork 1
Build Cache
Sia edited this page May 31, 2026
·
2 revisions
View and selectively clean Gradle / Android / npm caches at
/settings/cache (left nav: "빌드 캐시").
After a few months of regular use, the biggest disk consumers are:
| Directory | Typical size | Use |
|---|---|---|
~/.gradle/caches/ |
1–4 GB | downloaded JAR/AAR dependencies, Maven Local |
~/.gradle/daemon/ |
50–500 MB | JVM warm pool, daemon logs |
~/.android/cache/ |
100 MB–2 GB | SDK manager cache, AVD snapshots |
~/.npm/_cacache/ |
200 MB–1 GB | npm package + tarball cache (MCP installs) |
The /settings/cache page measures each on demand (Files.walk + size
sum) and offers per-target "정리" buttons. Clicking clears the contents
of the directory but leaves the directory itself (so Gradle/npm doesn't
panic about a missing path).
- Disk usage alert fired (see Disk Monitor) and you don't want to immediately upgrade the host.
- Suspected cache corruption — Gradle "could not resolve" errors that re-running doesn't fix.
- Before a snapshot / backup — caches are reproducible from the network, so dropping them shrinks your tar by gigabytes.
-
A build is currently running. Gradle holds file locks on cache
entries; cleaning mid-build won't crash anything (the routine catches
the resulting
IOExceptionper-file), but you'll get a half-cleared cache and the running build may fail in unpredictable ways. - You're about to fly / go offline. First builds after a clean re-fetch every dependency; budget 5–15 min on a slow connection.
BuildCacheService.cleanup(target):
- Resolves the path against
userHome(~/.gradle/caches, etc.). -
Files.walk(path).sorted(Comparator.reverseOrder())— bottom-up. - For each entry (not the root itself):
Files.delete. Catches per-file exceptions and continues (so a locked file won't abort the whole walk). - Returns
(deletedFiles, freedBytes, errorMessage).
The walk is sequential — for very large caches this can take 10–30 s. No spinner today; the form just blocks until done.
- The target list is a fixed enum (
GRADLE_CACHES,GRADLE_DAEMON,ANDROID_CACHE,NPM_CACHE) — no arbitrary path is accepted from the form, so there's no path-traversal vector. - CSRF protects the POST. JS confirm dialog ("다음 빌드에서 재다운로드 발생합니다") makes accidental clicks unlikely.
- Permission errors (files owned by another UID) are silently skipped; the result row reports only what actually got removed.
- Async cleanup with progress bar (long walks block the form thread).
- Optional auto-cleanup schedule when disk usage > N% — would combine with the disk monitor's existing alert hook.