iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more
Angular CLI’s ng cache command manages persistent disk caching: it lets you inspect the cache, delete it, or enable and disable it. Angular CLI uses cached operations to reuse eligible work across runs. The cache is enabled by default for local development and stored in .angular/cache; you can change those settings in your workspace’s angular.json.
What does Angular’s persistent cache do?
Angular CLI saves eligible operations to disk so a later run can restore prior build state and reuse work already completed. Angular says this can reduce build and test time, but its documentation does not give a measured speedup or guarantee a particular improvement.
The cache is persistent across command runs, unlike temporary data held only while a process is running. Angular CLI’s ng cache commands manage this disk cache for workspace projects.
What do the ng cache subcommands do?
| Command | Effect |
|---|---|
ng cache info |
Prints cache configuration and statistics in the console. |
ng cache clean |
Deletes the persistent cache from disk. |
ng cache enable or ng cache on |
Enables persistent disk caching for all workspace projects. |
ng cache disable or ng cache off |
Disables persistent disk caching for all workspace projects. |
Run these from an Angular workspace using its CLI. The commands manage cache behavior or stored data; they do not change the application’s source files.
#1 Best Overall
How do you check or clear the cache?
Inspect its settings and statistics
Run ng cache info in the workspace. The CLI prints the current cache configuration and available statistics, which can help confirm whether caching is enabled and where it is configured.
Delete stored cache data
Run ng cache clean when you deliberately want to remove persistent cache data. Angular documents this command as deleting the disk cache; it does not promise to fix every build failure, so treat it as a reset rather than a universal troubleshooting remedy.
Rank #2
Where are the defaults configured?
Cache settings live in the top-level cli.cache object in workspace angular.json, outside the projects section. Angular’s workspace configuration reference documents these defaults:
| Setting | Documented default | Meaning |
|---|---|---|
enabled |
true |
Persistent disk caching is enabled. |
environment |
local |
Caching applies to development machines. |
path |
.angular/cache |
Cache files are stored under this workspace-relative directory. |
For example, a workspace configuration can be written as:
Rank #3
{
"cli": {
"cache": {
"enabled": true,
"environment": "local",
"path": ".angular/cache"
}
}
}
Angular’s defaults and command behavior can change between CLI releases; consult the current Angular CLI cache reference and workspace configuration reference for the version in use.
How do you change the cache environment or location?
Choose where caching is active
The environment option accepts local, ci, or all. The CLI checks the presence and value of the CI environment variable to determine whether it is running in a continuous-integration environment.
Rank #4
local: development machines.ci: continuous-integration systems.all: both local and CI environments.
To enable caching across environments, Angular documents this command:
Do these 3 things before closing this tab:
1Scan for outdated or missing drivers - takes under a minute2Repair Windows errors before they cause bigger problems3Fix the driver behind crashes, sound loss and screen glitchesng config cli.cache.environment all
To configure the option for CI only, use ng config cli.cache.environment ci. For local-only caching, use ng config cli.cache.environment local. These commands update workspace configuration; they do not themselves delete cache files.
Change the cache directory
Set cli.cache.path to choose another directory. Angular’s example is:
ng config cli.cache.path ".cache/ng"
This changes where the CLI stores cache data; it is not a cache-cleaning command.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.How do you enable Angular caching in CI?
- Set the workspace cache environment. From the workspace, run
ng config cli.cache.environment ci, or set the value toallif the cache should also run on development machines. - Check the CI environment detection. Angular CLI uses the
CIenvironment variable to determine its environment. Make sure the CI job sets it appropriately for the system running the build. - Confirm the configuration. Run
ng cache infoto see the cache configuration and statistics reported by the CLI.
Persistent caching reuses eligible local disk data across runs on the machine. The cited Angular documentation describes this disk cache; it does not establish a remote or shared cache between separate CI workers.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Why might you keep caching enabled during development?
Angular’s ng serve reference says development-server prebundling requires Angular CLI caching to be enabled. Disabling the persistent cache can therefore affect that prebundling behavior, in addition to preventing reuse of other eligible cached operations.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

