Use Remote Caching (Nx Replay)

By default Nx caches task computations locally. However, to benefit from the cache across your team and in particular on CI, the computation cache can also be distributed across multiple machines.

The Nx Replay feature of Nx Cloud is a fast, secure and zero-config implementation of remote caching.

Diagram showing Teika sharing his cache with CI, Kimiko and James

In this diagram, Teika runs the build once on his machine, then CI, Kimiko and James can use the cached artifact from Teika instead of re-executing the same work.

Setting Up Nx Cloud

To use Nx Replay you need to connect your workspace to Nx Cloud. See the connect to Nx Cloud recipe.

See Remote Caching in Action

To see the remote cache in action, run:

~/workspace

nx build header && nx reset && nx build header

1> nx run header:build 2 3> header@0.0.0 build 4> rimraf dist && rollup --config 5 6src/index.tsx → dist... 7created dist in 786ms 8 9————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— 10 11NX Successfully ran target build for project header (2s) 12 13See logs and investigate cache misses at https://cloud.nx.app/runs/k0HDHACpL8 14 15NX Resetting the Nx workspace cache and stopping the Nx Daemon. 16 17This might take a few minutes. 18 19NX Daemon Server - Stopped 20 21NX Successfully reset the Nx workspace. 22 23 24> nx run header:build [remote cache] 25 26 27> header@0.0.0 build 28> rimraf dist && rollup --config 29 30 31src/index.tsx → dist... 32created dist in 786ms 33 34————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— 35 36NX Successfully ran target build for project header (664ms) 37 38Nx read the output from the cache instead of running the command for 1 out of 1 tasks. 39 40Nx Cloud made it possible to reuse header: https://nx.app/runs/P0X6ZGTkqZ 41

Skipping Cloud Cache

Similar to how --skip-nx-cache will instruct Nx not to use the local cache, passing --no-cloud will tell Nx not to use the remote cache from Nx Cloud.