|
| 1 | +- Start Date: 2017-03-14 |
| 2 | +- RFC PR: |
| 3 | +- Yarn Issue: [yarnpkg/yarn#986](https://github.com/yarnpkg/yarn/issues/986) |
| 4 | + |
| 5 | +# Summary |
| 6 | + |
| 7 | +Allow users to bypass the global cache. |
| 8 | + |
| 9 | +# Motivation |
| 10 | + |
| 11 | +For certain situations, it would be preferrable to not use a global cache for |
| 12 | +packages because the cache takes space and the step of copying from the cache |
| 13 | +to `node_modules` can take a significant amount of time. Some examples are: |
| 14 | + |
| 15 | +1. Building a Docker image. Images are isolated, so there's no point in having |
| 16 | +a cache within the image. If anything, it has the negative effect of increasing |
| 17 | +the image size. |
| 18 | + |
| 19 | +2. Running Yarn in a CI context. This is another example of a potentially |
| 20 | +isolated environment where we would just want to put the installed packages |
| 21 | +directly into `node_modules`. While sophisticated CI setups might have |
| 22 | +multiple projects share the same cache, there are certainly setups that don't |
| 23 | +do that. |
| 24 | + |
| 25 | +3. Running Yarn on a long-running server. The cache grows indefinitely over |
| 26 | +time, eventually reaching max disk size or inode limit. Simply bypassing the |
| 27 | +cache at run time could be preferrable to having to periodically run `yarn cache |
| 28 | +clean`. |
| 29 | + |
| 30 | +Overall, the desired effects of bypassing the cache are to increase the speed |
| 31 | +and decrease the disk usage of certain Yarn commands (i.e., install, add, |
| 32 | +upgrade). |
| 33 | + |
| 34 | +# Detailed design |
| 35 | + |
| 36 | +There should be a CLI switch `--no-cache` that tells Yarn to skip doing any work |
| 37 | +with the cache. |
| 38 | + |
| 39 | +Furthermore, there could be an equivalent `.yarnrc` setting of `no-cache` that |
| 40 | +does the same thing when set to `true`. This way, the developer doesn't need to |
| 41 | +remember to use the CLI switch every time. |
| 42 | + |
| 43 | +# How We Teach This |
| 44 | + |
| 45 | +We would update the [documentation](https://yarnpkg.com/en/docs/cli/cache) for |
| 46 | +the `yarn cache` command. |
| 47 | + |
| 48 | +# Drawbacks |
| 49 | + |
| 50 | +Increases the complexity of the implementation of Yarn. |
| 51 | + |
| 52 | +# Alternatives |
| 53 | + |
| 54 | +In the linked issue, there is a suggestion to set the cache folder to some |
| 55 | +in-memory or temporary location, but this solution is hacky and doesn't really |
| 56 | +help with the speed concern because Yarn still has to do the work of copying |
| 57 | +the packages to `node_modules`. |
| 58 | + |
| 59 | +The same reasoning applies to the option of immediately running |
| 60 | +`yarn cache clean`. |
| 61 | + |
| 62 | +# Unresolved questions |
0 commit comments