Add configurable size limit for persistent build cache with LRU eviction
- Dominant language
- TypeScript
- Stars
- 27k
- Forks
- 11.8k
- Avg merge
- 14h 23m
- Merged PRs (30d)
- 162
Description
### Command
build, serve
### Description
The Angular CLI persistent disk cache (`.angular/cache`) grows without bounds. On large projects, a single checkout accumulates tens of gigabytes of cached build artifacts. In our case, a single checkout reached **29 GB**.
This was previously raised in #25116 and closed as not feasible with Webpack. Since Angular 17+, the build system uses esbuild, so the original constraint no longer applies.
### Describe the solution you'd like
Add a configurable size cap (e.g., `cli.cache.maxSize`) with LRU eviction when the limit is reached. This is a common pattern in build tooling — Turborepo, Gradle, and most browsers' HTTP caches all implement bounded persistent caches.
Example configuration:
```json
"cli": {
"cache": {
"enabled": true,
"maxSize": "2GB"
}
}
```
When the cache exceeds `maxSize`, the oldest/least-recently-used entries are evicted.
### Describe alternatives you've considered
- Periodically running `ng cache clean` or manually deleting `.angular/cache` — works but is a manual maintenance burden, especially for developers unaware the cache is growing.
Contributor guide
Research direction
Start with the persistent cache used by the `build` and `serve` commands, and compare it with the existing `ng cache clean` entry point for `.angular/cache`. Define how `cli.cache.maxSize` is configured and measured, then verify that least-recently-used entries are evicted once the configured cap is exceeded.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- angular, typescript
- Domain
- build-system, cli
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100