Skip to content

Nx caches task results locally so the same machine doesn't repeat a task with the same inputs. Remote caching shares those results across developer machines and CI jobs.

Three developers and CI sharing cached task results

On a remote cache hit, Nx restores the terminal output and declared task artifacts, such as a build or distribution directory. The command behaves like a local cache hit without running the task again.

Connect your workspace to Nx Cloud:

Terminal window
npx nx@latest connect

For authentication and CI setup details, see set up CI.

Remote caching can reduce work in several places:

  • Repeated CI runs can reuse tasks that already ran with the same inputs.
  • Developers can reuse results created in CI when their cache permissions grant access.
  • CI jobs and Nx Agents can transfer task artifacts through the shared cache.

Remote caching complements affected tasks. Affected calculations remove projects that don't need a task, while caching avoids rerunning matching tasks in the remaining graph.

Nx Agents use remote caching to share artifacts between machines. When a task depends on output produced by another agent, Nx restores that output before running the dependent task.

Each cached task result contains:

  • Terminal output written to standard output and standard error.
  • Files matched by the task's outputs configuration.
  • The hash that identifies the task computation.

The cache entry doesn't contain the input source files. Nx hashes those inputs to calculate the task hash. For more information, see how caching works.

Cache correctness depends on accurate inputs and outputs. A missing input can produce a stale cache hit, while an undeclared output won't be restored. Task sandboxing can identify file access that isn't represented in the task configuration.

Nx Cloud protects cached results with several controls:

  • Cache entries are immutable after they're written.
  • Access tokens control read and write permissions.
  • End-to-end encryption is available for task artifacts.
  • Enterprise plans offer regional and self-hosted deployment options.

Configure token permissions so developer machines can read cached results while trusted CI jobs write them. For the permission model and protection against cache poisoning, see cache security.

For end-to-end encryption setup, see encryption. Nx publishes current compliance information on the Nx security site.

Nx checks the local cache before requesting a result from the remote cache. If the remote cache is unavailable, local cache hits remain available, and Nx runs tasks that aren't cached locally.

Organizations with specific data residency or infrastructure requirements can contact the Nx Enterprise team to discuss remote caching deployment options.

Use --skipRemoteCache when one command shouldn't read from or write to the remote cache. For related local cache options, see skip task caching.