Cache task

Azure DevOps Services

Note

This task is only available in Azure DevOps Services.

Improve build performance by caching files, like dependencies, between pipeline runs.

Demands

None

YAML snippet

# Cache
# Cache files between runs
- task: Cache@2
  inputs:
    key: 
    path: 
    #cacheHitVar: # Optional
    #restoreKeys: # Optional

Arguments

Argument Description
Key (unique identifier) for the cache This should be a string that can be segmented using '|'. File paths can be absolute or relative to $(System.DefaultWorkingDirectory).
Path of the folder to cache Can be fully qualified or relative to $(System.DefaultWorkingDirectory). Wildcards are not supported. Variables are supported.
Cache hit variable Variable to set to 'true' when the cache is restored (a cache hit), otherwise set to 'false'.
Additional restore key prefixes Additional restore key prefixes that are used if the primary key misses. This can be a newline-delimited list of key prefixes.

Control options

Open-source

This task is open source on GitHub. Feedback and contributions are welcome.

Next steps