Add configurable size limit for persistent build cache with LRU eviction
- Langage dominant
- TypeScript
- Étoiles
- 27k
- Forks
- 11.8k
- Merge moyen
- 14 h 23 min
- PR mergées (30 j)
- 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.
Guide de contribution
Ouvrir le guide de contribution
Piste de recherche
Commencez par le cache persistant utilisé par les commandes `build` et `serve`, puis comparez-le au point d’entrée existant `ng cache clean` pour `.angular/cache`. Définissez comment `cli.cache.maxSize` est configuré et mesuré, puis vérifiez que les entrées les moins récemment utilisées sont supprimées une fois la limite configurée dépassée.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- angular, typescript
- Domaine
- build-system, cli
- Type d'issue
- Fonctionnalité
- Difficulté
- 5/5
- Temps estimé
- Plus d'une semaine
- Activité
- Active
- Clarté
- Plutôt claire
- Accessibilité débutants
- 45/100