Skip to content

Add configurable size limit for persistent build cache with LRU eviction #33320

Description

@aqeelat

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions