Angular CLI - ng cache Command



The ng cache command manages the persistent disk cache, which stores cachable operations like build and test data to speed up processes.

Cache in Angular CLI

The cache is a storage space in Angular CLI where the state and data of cachable operations are stored. These operations include build, test, serve and more. It speeds up the processes because when you re-run the same build, it restores the previous build state and re-uses previously performed operations. As a result, a lot of time is saved while building and testing your applications. By default, the cache results are stored in .angular/cache directory.

Syntax

Following is the syntax of ng cache command −

ng cache [options]

Options

Options are optional parameters of ng cache command.

Sr.No. Option & Syntax Description
1 help Shows a help message for this command in the console. Default: false

Sub-Commands of ng cache Command

This command has the following sub-commands −

  • ng cache clean: This sub-command is used to delete persistent disk cache from disk.

  • ng cache disable: It is used to disable disk cache for all projects. You can also use ng cache off command for the same.

  • ng cache enable: It is used to enable disk cache for all projects. You can also use ng cache on command for the same.

  • ng cache info: It prints the stored persistent disk cache configuration and statistics in the console.

Example

Here, we use ng cache info command to display the cache information in the console −

PS D:\Angular\flex-app> ng cache info
Enabled: yes
Environment: local
Path: D:\Angular\flex-app\.angular\cache
Size on disk: 0 bytes
Effective status on current machine: enabled

Similarly, you can use other sub-commands. But, they will not display any result in the console.

Advertisements