xref: /expo/docs/pages/build-reference/caching.mdx (revision dfd15ebd)
1---
2title: Caching dependencies
3---
4
5Before 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.
6
7> We're actively working on improving caching and other aspects of the build process in order to make builds reliably fast.
8
9## Custom caching
10
11The `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.
12
13The caching implementation is built on top of Amazon S3, and it's not fast enough to give you any benefit from caching `node_modules` or CocoaPods; it's intended only for files that require significant computation to generate, e.g. compilation results (both final binaries and any intermediate files).
14
15## JavaScript dependencies
16
17EAS 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](how-tos/#using-npm-cache-with-yarn-v1).
18
19It is not yet possible to save and restore `node_modules` between builds.
20
21To disable using our npm cache server for your builds set `EAS_BUILD_DISABLE_NPM_CACHE` env variable value to `"1"` in `eas.json`.
22
23```json
24{
25  "build": {
26    "production": {
27        "env": {
28            "EAS_BUILD_DISABLE_NPM_CACHE": "1",
29            // ...
30        }
31        // ...
32    }
33    // ...
34  }
35  // ...
36}
37```
38
39## Android dependencies
40
41EAS Build runs a Maven cache server that can speed up downloading Android dependencies for your build jobs.
42
43Currently we are caching:
44
45- `maven-central` - [https://repo1.maven.org/maven2/](https://repo1.maven.org/maven2/)
46- `google` - [https://maven.google.com/](https://maven.google.com/)
47- `jcenter` - [https://jcenter.bintray.com/](https://jcenter.bintray.com/)
48- `plugins` - [https://plugins.gradle.org/m2/](https://plugins.gradle.org/m2/)
49
50To disable using our Maven cache server for your builds set `EAS_BUILD_DISABLE_MAVEN_CACHE` env variable value to `"1"` in `eas.json`.
51
52```json
53{
54  "build": {
55    "production": {
56        "env": {
57            "EAS_BUILD_DISABLE_MAVEN_CACHE": "1",
58            // ...
59        }
60        // ...
61    }
62    // ...
63  }
64  // ...
65}
66```
67
68## iOS dependencies
69
70EAS Build runs a CocoaPods cache server that can speed up downloading iOS dependencies for your build jobs. It also makes the service more resilient to CocoaPods CDN outages.
71
72Currently, EAS Build is configured to cache almost all the pods served from official CocoaPods CDN, minus few exceptions which can't be handled by our cache server. These exceptions can be found on the [blacklist](https://github.com/expo/eas-build/blob/main/packages/cocoapods-nexus-plugin/lib/cocoapods_plugin.rb#L4) of our custom CocoaPods plugin and are fetched directly from CDN instead of being fetched through our cache server.
73
74We also cache `Podfile.lock` to provide consistent results across managed app builds.
75
76To disable using our CocoaPods cache server for your builds set `EAS_BUILD_DISABLE_COCOAPODS_CACHE` env variable value to `"1"` in `eas.json`.
77
78```json
79{
80  "build": {
81    "production": {
82        "env": {
83            "EAS_BUILD_DISABLE_COCOAPODS_CACHE": "1",
84            // ...
85        }
86        // ...
87    }
88    // ...
89  }
90  // ...
91}
92```
93