Description
DVC cache commands help you configure and manage the local cache directory where DVC stores all tracked data and model files. The cache enables efficient storage and sharing of large files across your project.Subcommands
cache dir
Configure cache directory location.Arguments
Path to cache directory. If no path is provided, it returns the current cache directory.
- Relative paths are resolved relative to the current directory
- Path is saved to config relative to the config file location
- Default location:
.dvc/cachewithin your project
Options
Unset the custom cache directory and revert to default location (
.dvc/cache).Use global config (~/.config/dvc/config).
Use system config.
Use project config (.dvc/config).
Use local config (.dvc/config.local).
cache migrate
Migrate cached files to the DVC 3.0 cache location.Options
Migrate entries in all existing DVC files in the repository to the DVC 3.0 format.
Only print actions which would be taken without actually migrating any data.
Examples
View Current Cache Location
Move Cache to External Drive
Share Cache Across Multiple Projects
Reset to Default Location
Preview Cache Migration
Use
--dry to safely preview migration before committing to changes.Migrate to DVC 3.0 Format
Cache Structure
DVC uses content-addressable storage where files are stored by their hash:- Files are stored using their MD5 hash
- First 2 characters of hash become directory name
- Rest of hash is the filename
- Same file content = same cache entry (deduplication)
Cache Configuration Options
You can configure additional cache behaviors viadvc config:
Cache Type (File Links)
hardlink
hardlink
Creates hard links to cache files. Fast and space-efficient. Default option.
symlink
symlink
Creates symbolic links to cache files. Good for read-only workflows.
reflink
reflink
Copy-on-write links (requires Btrfs, XFS, or APFS). Best of both worlds when supported.
copy
copy
Full file copies. Slowest but most compatible. Use when links aren’t available.
Protected Mode
Shared Cache
Use Cases
External Storage
Move cache to external drive when local disk space is limited.
Shared Team Cache
Configure a network location for cache to enable team collaboration without redundant downloads.
CI/CD Optimization
Use persistent cache directories in CI to speed up pipeline runs.
Version Upgrade
Migrate from DVC 2.x to 3.0 cache format for improved performance.
Cache vs Remote Storage
| Feature | Cache | Remote |
|---|---|---|
| Location | Local machine | Cloud/Network |
| Purpose | Fast file access | Backup & sharing |
| Required | Yes | No (but recommended) |
| Shared | Can be network-mounted | Yes |
| Configuration | dvc cache dir | dvc remote add |
Troubleshooting
Check Cache Size
Clear Cache
dvc pull to restore files from remote.
Verify Cache Integrity
Related Commands
dvc config- Configure DVC settings including cache optionsdvc gc- Garbage collect unused cache filesdvc pull- Download files from remote to cachedvc push- Upload files from cache to remotedvc status- Check status of tracked files and cache