Add configurable size limit for persistent build cache with LRU eviction

Open
#33,320 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
45/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Active
Tech stack
angular, typescript
Domain
build-system, cli

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.

Description

area: @angular/cli gemini-triaged needs: more info
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:

"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.
Dominant language
TypeScript
Stars
27k
Forks
11.8k
Avg merge
16h 35m
Merged PRs (30d)
176

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from angular/angular-cli

All issues in angular/angular-cli

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.