1--- 2title: Cache dependencies 3description: Learn how to speed up your builds by caching dependencies. 4--- 5 6Before a build job can begin compiling your project, all project dependencies need to be available on disk. The longer it takes to acquire the dependencies, the more you need to wait for your build to complete — so caching dependencies is an important part of speeding up your builds. 7 8> We're actively working on improving caching and other aspects of the build process to make builds reliably fast. 9 10## Custom caching 11 12The `cache` field on build profiles in [eas.json](/build/eas-json) can be used to configure caching for specific files and directories. Specified files will be saved to persistent storage after a successful build and restored on subsequent builds after the JavaScript dependencies are installed. Restoring does not overwrite existing files. Changing the `cache.key` value will invalidate the cache. Changing any other property of the `cache` object will also invalidate the cache. 13 14## JavaScript dependencies 15 16EAS Build runs an npm cache server that can speed up downloading JavaScript dependencies for your build jobs. Projects that are using npm or yarn v2 will use the cache by default, but yarn v1 will require that you apply this [workaround](/build-reference/npm-cache-with-yarn). 17 18To disable using our npm cache server for your builds set the `EAS_BUILD_DISABLE_NPM_CACHE` env variable value to `"1"` in **eas.json**. 19 20{/* prettier-ignore */} 21```json eas.json 22{ 23 "build": { 24 "production": { 25 "env": { 26 "EAS_BUILD_DISABLE_NPM_CACHE": "1" 27 /* @hide ... */ /* @end */ 28 } 29 /* @hide ... */ /* @end */ 30 } 31 /* @hide ... */ /* @end */ 32 } 33 /* @hide ... */ /* @end */ 34} 35``` 36 37## Android dependencies 38 39EAS Build runs a Maven cache server that can speed up downloading Android dependencies for your build jobs. 40 41Currently, we are caching: 42 43- `maven-central` - [https://repo1.maven.org/maven2/](https://repo1.maven.org/maven2/) 44- `google` - [https://maven.google.com/](https://maven.google.com/) 45- `jcenter` - [https://jcenter.bintray.com/](https://jcenter.bintray.com/) 46- `plugins` - [https://plugins.gradle.org/m2/](https://plugins.gradle.org/m2/) 47 48To disable using our Maven cache server for your builds set the `EAS_BUILD_DISABLE_MAVEN_CACHE` env variable value to `"1"` in **eas.json**. 49 50{/* prettier-ignore */} 51```json eas.json 52{ 53 "build": { 54 "production": { 55 "env": { 56 "EAS_BUILD_DISABLE_MAVEN_CACHE": "1" 57 /* @hide ... */ /* @end */ 58 } 59 /* @hide ... */ /* @end */ 60 } 61 /* @hide ... */ /* @end */ 62 } 63 /* @hide ... */ /* @end */ 64} 65``` 66 67## iOS dependencies 68 69EAS Build serves most CocoaPods artifacts from a cache server. This improves the consistency of `pod install` times and generally improves speed. The cache will be bypassed automatically if you provide your own **.netrc** or **.curlrc** files. 70 71To use our CocoaPods cache server for your builds set the `EAS_BUILD_DISABLE_COCOAPODS_CACHE` env variable value to `"1"` in **eas.json**. 72 73{/* prettier-ignore */} 74```json eas.json 75{ 76 "build": { 77 "production": { 78 "env": { 79 "EAS_BUILD_DISABLE_COCOAPODS_CACHE": "1" 80 /* @hide ... */ /* @end */ 81 } 82 /* @hide ... */ /* @end */ 83 } 84 /* @hide ... */ /* @end */ 85 } 86 /* @hide ... */ /* @end */ 87} 88``` 89 90It is typical to not have your project **Podfile.lock** committed to source control when using [prebuild](/workflow/prebuild) to generate your **ios** directory [remotely at build time](/build-reference/ios-builds). 91It can be useful to cache your **Podfile.lock** to have deterministic builds, but the tradeoff in this case is that, because you don't use the lockfile during local development, your ability to determine when a change is needed and to update specific dependencies is limited. 92If you cache this file, you may occasionally end up with build errors that require clearing the cache. 93To cache **Podfile.lock**, add **./ios/Podfile.lock** to the `cache.paths` list in your build profile in **eas.json**. 94 95{/* prettier-ignore */} 96```json eas.json 97{ 98 "build": { 99 "production": { 100 "cache": { 101 "paths": ["./ios/Podfile.lock"] 102 /* @hide ... */ /* @end */ 103 } 104 /* @hide ... */ /* @end */ 105 } 106 /* @hide ... */ /* @end */ 107 } 108 /* @hide ... */ /* @end */ 109} 110``` 111