Angular - NG Cache

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

ng cache

Con�gure persistent disk cache and retrieve cache statistics.

ng

Description 

Angular CLI saves a number of cachable operations on disk by default.

When you re-run the same build, the build system restores the state of

the previous build and re-uses previously performed operations, which

decreases the time taken to build and test your applications and

libraries.

To amend the default cache settings, add the cli.cache object to your

Workspace Con�guration. The object goes under cli.cache at the top

level of the �le, outside the projects sections.

{
"$schema": ".∕node_modules∕@angular∕cli∕lib∕config
∕schema.json",
"version": 1,
"cli": {
"cache": {
∕∕ ...
}
},
"projects": {}
}
For more information, see cache options.

Cache environments
By default, disk cache is only enabled for local environments. The value

of environment can be one of the following:

• all - allows disk cache on all machines.

• local - allows disk cache only on development machines.

• ci - allows disk cache only on continuous integration (CI)


systems.

To change the environment setting to all , run the following command:

ng config cli.cache.environment all

For more information, see environment in cache options.

The Angular CLI checks for the presence and value of the CI

environment variable to determine in which environment it is

running.

Cache path
By default, .angular∕cache is used as a base directory to store cache

results.

To change this path to .cache∕ng , run the following command:

ng config cli.cache.path ".cache∕ng"

This command has the following sub-commands:


• clean

• disable

• enable

• info

Options
VALUE DEFAULT
OPTION DESCRIPTION
TYPE VALUE

--help Shows a help message boolean

for this command in

the console.

Cache commands
clean

ng cache

Deletes persistent disk cache from disk.

disable

ng cache

ng cache
Disables persistent disk cache for all projects in the workspace.

enable

ng cache

ng cache

Enables disk cache for all projects in the workspace.

info

ng cache

You might also like