Cache task

Azure Pipelines | Azure DevOps Server 2020 | Azure DevOps Server 2019 | TFS 2018 | TFS 2017

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



YAML snippet

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


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


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

Next steps

Learn more about pipeline caching:

Pipeline Caching