
Deploy Nx Custom Cache | Open Source Nx Cloud Alternative for Monorepos
Self-hosted Nx remote cache on your own bucket
nx-cache-server
Just deployed
Bucket
Bucket
Just deployed
Deploy and Host Nx Custom Cache on Railway
Nx Custom Cache is a self-hosted remote cache for Nx monorepos. Tasks built on one machine are reused on every other machine and in CI — the same acceleration Nx Cloud sells, backed by your own S3 bucket and priced like storage.
About Hosting Nx Custom Cache
A single small service implementing the Nx remote cache API, with artifacts stored in a Railway bucket rather than on a volume. Nx clients authenticate with a generated access token and read and write cache entries over HTTPS.
Since Nx 21 the remote cache is an official plugin interface, so this needs no patched Nx and no wrapper around your build commands.
Common Use Cases
- Cutting CI time on a monorepo: A pull request that touches one library reuses everything else from cache instead of rebuilding the graph.
- Sharing a cache across a team: The first person to build a target pays for it; everyone else downloads the result.
- Leaving Nx Cloud: The same speed-up without per-user or per-task pricing, with artifacts in a bucket you own.
Dependencies for Nx Custom Cache Hosting
Deployment Dependencies
- The nx-cache-server image
- A Railway bucket for cache artifacts
- Nx 21 or newer with
@nx/remote-cache(or the equivalent custom-cache configuration) in your workspace
Implementation Details
NX_CACHE_ACCESS_TOKEN is generated per deployment and is the only credential between the public domain and your cache. On the client side it goes into NX_SELF_HOSTED_REMOTE_CACHE_ACCESS_TOKEN, alongside NX_SELF_HOSTED_REMOTE_CACHE_SERVER pointing at this deployment's URL. In CI, both belong in secrets.
Bucket credentials are wired in from the Railway bucket, so there is no S3 account to create and no keys to paste.
A remote cache is a trusted input to your build. Anyone who can write to it can poison future builds with a forged artifact, which is precisely why the token matters and why it should not be shared beyond people who can already push code.
Cache entries are content-addressed by Nx's task hash, so nothing is ever overwritten and stale entries are simply never requested again — but they are also never deleted. Set a lifecycle rule on the bucket if the monorepo is large.
Why Deploy Nx Custom Cache on Railway?
Railway is a singular platform to deploy your infrastructure stack. Railway will host your infrastructure so you don't have to deal with configuration, while allowing you to vertically and horizontally scale it.
By deploying Nx Custom Cache on Railway, you are one step closer to supporting a complete full-stack application with minimal burden. Host your servers, databases, AI agents, and more on Railway.
Resources: tiny — the server is a thin layer over object storage and idles at a few tens of megabytes, a few dollars a month. Cost follows bucket size and transfer, not the service itself.
Template Content
nx-cache-server
ghcr.io/ikatsuba/nx-cache-server:1.1Bucket
Bucket
