October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PCOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk3 min

Angular `ng cache`: What It Does, How to Clear It, and Configure It

Angular CLI’s ng cache commands inspect, clear, enable, or disable persistent disk caching. Configure its environment and storage path in angular.json.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Angular CLI’s ng cache command manages persistent disk caching for workspace projects. It can show cache details, delete stored cache data, or turn caching on and off. Cache settings—including whether it applies locally or in CI and where files are stored—are configured in the workspace’s top-level cli.cache section of angular.json.

What does Angular’s ng cache do?

Angular CLI stores eligible operations on disk so it can reuse work on a later run. Angular says that rerunning the same build can restore the previous build state and reuse previously performed operations, reducing build and test time. The documentation does not quantify that reduction, so the benefit depends on the work being cached and the project.

As an Amazon Associate I earn from qualifying purchases.

The cache is persistent between runs, unlike temporary in-memory state. Its documented default location is .angular/cache in the workspace.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

What are the ng cache subcommands?

Command What it does
ng cache info Prints cache configuration and statistics in the console. Angular CLI reference.
ng cache clean Deletes persistent cache data from disk. Angular CLI reference.
ng cache enable or ng cache on Enables persistent disk caching for all projects in the workspace. Angular CLI reference.
ng cache disable or ng cache off Disables persistent disk caching for all projects in the workspace. Angular CLI reference.

These operations are different: info inspects settings and statistics, clean removes stored data, and enable/disable change whether caching is used. Cleaning the cache is not documented as a universal fix for build failures.

How do you check or clear the Angular cache?

Inspect the current cache

  1. Open a terminal in the Angular workspace.
  2. Run ng cache info to print its configuration and statistics.

Delete persistent cache data

  1. Open a terminal in the Angular workspace.
  2. Run ng cache clean. The command deletes the persistent disk cache; Angular’s command reference does not say that it removes other workspace files.

How do you enable Angular caching in CI?

The cache environment setting accepts local, ci, or all. Angular CLI uses the presence and value of the CI environment variable to determine the environment in which it is running. To include CI systems, set the environment to ci or all in workspace configuration. To apply caching on all machines, Angular also documents this command:

ng config cli.cache.environment all

For example, the top-level workspace configuration can be set as follows:

{
  "cli": {
    "cache": {
      "enabled": true,
      "environment": "ci",
      "path": ".angular/cache"
    }
  }
}

Use "environment": "all" instead of "ci" if the cache should apply on both development machines and CI systems. The setting belongs in the top-level cli.cache object in angular.json, outside the projects section. See Angular’s workspace configuration reference and cache overview.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

How do you change the cache location or default?

Angular documents these workspace defaults: caching enabled, environment set to local, and cache path set to .angular/cache. Change them under cli.cache in angular.json. For example, Angular shows this command for changing the path:

ng config cli.cache.path ".cache/ng"

This changes the configured cache directory; it is not a command to delete cache files. Set enabled to false in the workspace configuration to disable caching by default, or use ng cache disable to disable it for all workspace projects.

Why keep caching enabled for development?

Angular’s ng serve reference says development-server prebundling requires Angular CLI caching to be enabled. If you turn caching off, that documented prebundling requirement will no longer be met. See the Angular CLI ng serve reference.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Which cache setting should you choose?

Setting Effect Documented default
enabled Whether persistent disk caching is enabled. true
environment local applies on development machines; ci applies on continuous integration systems; all applies on all machines. local
path Directory used to store the cache. .angular/cache

These are the documented Angular workspace defaults; behavior and available options may vary in other Angular CLI releases. The official references cited here do not identify a release number.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

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.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Outdated Drivers Are Slowing You DownFree scan - exact matches

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.