There are 9 individual things to cache in CI (you might only know 1)
actions/cache only covers your dependencies. A CI job has 9 steps worth caching, from the runner binary to Docker layers, and each one needs a different approach.
Caching is the single most effective thing you can do to cut down on billing minutes by speeding up your workflows, since every CI runner is often a fresh, empty machine.
actions/cache or actions/setup-* only help with caching and restoring your code dependencies, but there’s a lot more to cache in a CI workflow.
In fact, there are 9 separate steps in a typical job that you can cache and each needs a different caching approach:
1. Start the runner#
If you want to run a GitHub Actions job in a machine, you need the runner binary installed on that machine.
Before any of the work starts, this app needs to always be fetched and downloaded, unless it’s already pre-baked into the VM image (which it usually is on GitHub-hosted machines, or with most other CI providers).
The runner binary also has to stay current because GitHub rejects a binary that isn’t updated within 30 days of the latest release. By default the runner auto-updates whenever it starts, but if you spawn an ephemeral VM per job, like RunsOn does, you can start it with the --disableupdate flag to skip the time it takes to fetch and install an update on every boot.

RunsOn images already come pre-baked with the latest version of the runner binary and since v3.6, RunsOn also ships its own fork of the runner binary and mirrors its releases in each stack’s S3 cache bucket along with the packages, refreshed hourly so that there’s never a stale version.
So if the image has no runner binary, or GitHub rejects the image’s runner version, the RunsOn agent (inside the EC2 VM) installs/updates it from S3 via the S3 VPC Endpoint in the same region instead of from GitHub.
This endpoint is free to use so there’s no egress charges and is also faster than going over the internet to reach GitHub.

2. Resolve all actions#
Another thing happens before a job starts to run: all the ‘actions’ get resolved and downloaded.
An action is a reusable program packaged in its own GitHub repository with the format owner/repo@ref: for example actions/cache@v4, actions/setup-node@v4, or any third-party action.
Now typically the runner asks GitHub for a download URL for the exact commit SHA each ref in the action name points to and downloads it if the archive isn’t already cached in the runner.
To save time, the official GitHub runner images pre-download a few popular actions (like actions/checkout) into a folder the runner checks first.
But this list gets stale till a new runner image is built and every other action is downloaded again on every job.

RunsOn’s runner fork changes the order of events: once the runner has resolved every ref to a SHA, it hands that list to the RunsOn agent before downloading anything. The agent then looks up every SHA in the S3 cache bucket at once:
- On a miss: the runner downloads the archive from GitHub as usual. Meanwhile, in the background, the agent downloads GitHub’s public archive without credentials, verifies it, and stores it in the bucket, so the next job anywhere in the stack gets a hit.
- On a hit: the agent verifies and writes the archive into the runner’s archive directory so the runner finds it locally, skipping the download.
The download sometimes happens twice, and that’s on purpose:
- the runner downloads with the job’s token, so private and internal actions keep working, but those are never stored (a stored action skips GitHub’s permission check, so any job on the stack could run a private action it shouldn’t have access to).
- the agent downloads public actions on its own, so only public code ever goes into the shared bucket.
So every public action you use gets cached across all jobs in the stack. The cache fills itself on the first miss and never goes stale.
A new version of an action is just a new SHA, and gets a new entry, with no image rebuild needed.

3. Checkout (via git fetch)#
This is the quintessential actions/checkout action that runs git fetch to download all the objects of the repo. By default, it’s only the latest commit (fetch-depth: 1).
This can still be slow when you want the full history in a big monorepo, or when 20 jobs in a matrix all fetch at once. On every request, GitHub also has to work out which objects you’re missing and bundle them into a pack, which takes its own time.
And there’s no native way to cache this. You can only fetch less: shallow clones, sparse checkouts, or partial clones.

With extras=git-cache, the RunsOn agent becomes a transparent proxy for git.
It adds an entry to the system git config that sends git’s traffic for https://github.com/ through the agent’s local server (127.0.0.1:6871), trusting a CA certificate the agent generates on every boot.
That lets the agent read the git protocol while forwarding every request to GitHub with the job’s own credentials, so GitHub still checks access on every fetch:
- On a miss: the pack streams from GitHub to git, and is copied into the S3 cache bucket at the same time. The copy is kept only if the pack’s own SHA-1 checksum verifies.
- On a hit: the stored pack streams straight from S3.
If 20 matrix jobs miss at once, one of them claims the fetch by creating a claim object in S3 with a conditional write (only one can succeed). That job fetches from GitHub while the others wait for its entry to appear.
This means GitHub builds the pack once instead of 20 times, and everyone else reads it from S3.

4. Install system packages#
When you use apt-get install to install system packages in the runner machine, 3 things happen:
- apt fetches the indexes or lists of available packages from Ubuntu
- then the
.debfiles - then installs them
Each index is a catalogue of available packages with its version, dependencies, file location and fingerprint. But it’s not signed by Ubuntu itself.
It’s the top-level InRelease file that Ubuntu signs which lists every index with its fingerprint, and this is the file apt ultimately has to trust when fetching system packages to update/install.
Ubuntu mirrors are unpredictably slow or rate-limited and since many jobs install the same packages everyday, the most common way to speed this whole process up is to preinstall a bunch of packages in the runner image itself.
That’s a big part of why GitHub’s ubuntu-latest image is so large.

Since v3.6, with extras=apt-cache, the RunsOn agent sits between apt and Ubuntu’s servers as a proxy. apt asks the agent, and the agent either answers from S3 or fetches the file from the archive over HTTPS and passes it on.
Files that never change are cached in S3: .deb files (whose names include their exact version) and indexes fetched by checksum (whose names are their checksum). The agent stores each with its SHA-256 as an S3 checksum, and S3 refuses any upload whose content doesn’t match it. The agent only serves a file whose stored checksum matches the one apt is about to check.
The file that changes, InRelease, is always fetched fresh. The agent keeps a copy only as a fallback for when the archive doesn’t answer.
So apt still verifies every single file the way it normally would, no matter where they came from. A file planted in the bucket can’t change what gets installed; at worst it costs one extra download from upstream.

5. Install toolchains and dependencies#
This is where actions/cache or actions/setup-* comes in, the one step GitHub covers natively.
2 layers here:
- the toolchain is the language runtime: Node, Go, Python, etc. GitHub’s runner images cache several versions of these in a directory (
/opt/hostedtoolcache) and theactions/setup-*checks this directory before downloading. - the dependencies are the libraries your lockfile contains:
npm ci,go mod download,pip installdownload hundreds or thousands of packages from their registries.
actions/cache is simple: download all the dependencies listed in the lockfile the first time, pack that directory into a tarball, key it to the lockfile hash and upload it to GitHub storage on Azure via the GitHub cache service API. You gotta mention the hash and restore key though.
setup-* with the cache: option does the same without having to mention the hash and restore key as it’s implied depending on the toolchain, making it simpler to use.
All this is pretty straightforward and works out, but still has limitations:
- the cache lives in GitHub storage on Azure so if your runners are not on GitHub you have to download it over the internet which is unreliably slow.
- GitHub evicts any entry unused for 7 days, and once a repo goes over its 10 GB cap, it evicts the oldest entries until it’s back under, so busy repos keep evicting their own cache.
- every restore downloads the whole tarball, even when the job only needs a slice of it.

RunsOn’s Magic Cache (extras=s3-cache) implements the same cache service API but moves the storage to your S3 cache bucket.
The client automatically finds the cache service through the ACTIONS_CACHE_URL and ACTIONS_RESULTS_URL env vars. The RunsOn agent points them at itself, http://<runner-ip>:6871.
Since the agent implements the same API, the client can’t tell the difference which means actions/cache, actions/setup-* or anything that talks to the GitHub cache API hits the agent instead of GitHub.
The agent then stores everything in your S3 cache bucket, with no 10 GB cap and downloads restores in parallel.
You don’t change a single line of your workflow, keep the same scoping rules and with cache isolation turned on, each job gets S3 credentials scoped to its own repo and branch.

6. Build the code#
Okay now this is where things get interesting.
We all know that compiling source code into machine code is CPU-bound, so a large codebase can take several minutes to build from scratch even if you change 1 line.
Modern build tools like Bazel, Gradle, Go, Cargo, sccache, ccache, Turborepo, Nx etc have all solved this problem by making builds incremental, splitting them into many small actions (compile this, link that, test foo).
If each action is deterministic, it is treated as a pure function and memoized: hash every input (command + compiler version + flags + env vars that matter etc) and record the output. If that hash has been seen before, reuse the recorded output instead of running that action again.
Problem is you don’t have these recorded outputs on a fresh CI machine so there are really 2 ways to get them in:
- either cache the whole build directory with
actions/cacheand it’ll ‘work’ but then again, these are hundreds or thousands of small files packed into a tarball. Unpacking them again will eat a lot of the time the caching saves in the first place. - or, use a remote cache. Here the build tool asks a server for the hash of a specific action, fetches it if it exists and uploads it if it doesn’t. This way it fetches the exact action it needs instead of the whole build in a tarball and moreover, parallel jobs can share the cache with each other - job 7 can reuse what job 3 compiled minutes ago.

Since v3.6, the RunsOn agent is that server. It speaks each tool’s own cache protocol on the runner and stores entries in your S3 bucket:
- Bazel through its HTTP remote cache
- sccache (Rust, C/C++) through WebDAV
- Turborepo through its remote cache API
- Nx through its self-hosted remote cache API (since v3.6.1)
- Go through
GOCACHEPROG - Gradle, ccache, mbx and others through a generic key/value endpoint
One step sets your tool up (with extras=s3-cache on the job):
- uses: runs-on/action@v2 with: remote_cache: bazel # or sccache, go, turbo, nx, gradleThat’s it, and you get the same scoping rules without a PR poisoning an action result main uses.

But there’s also a 3rd way to cache this with RunsOn:
If your build tool doesn’t have a remote cache, like for node_modules, a Cargo /target dir without sccache, or any huge tree of small files, you can use a StickyDisk (sticky=20gb): a job gets a dedicated EBS volume mounted at /mnt/runs-on/stickydisk.
When the job ends, the volume is snapshotted and unmounted safely, and the next job on the same branch and repo gets a volume restored from that snapshot.
No tarball - your build output stays on disk.
7. Run tests, sometimes with fixtures#
Tests are also CPU and I/O bound, making them the slowest part of any job, and the only native option on GitHub is skipping them entirely with paths: filters.
Fortunately all modern build tools mentioned in 6 also cover test outputs with the same principle: hash the test’s input, store the output and skip if the hash exists when running the tests again.
Fixtures that are expensive to create can be cached by the hash of whatever generates them.

On RunsOn, the remote caches from step 6 store those test results too, and fixtures go through Magic Cache or a StickyDisk.

8. Pull base Docker images#
Whenever you do a docker pull, or every FROM node:20 in a Dockerfile, you download the image’s layers.
Each layer is named by its hash so a layer with the same hash is always the same layer, making layers easy to cache.
But GitHub doesn’t cache these layers natively and Docker Hub has its own rate limits which a busy repo can definitely hit if the pulls are anonymous.
The usual workarounds are logging in for higher limits, copying images into another registry by hand, or docker save/docker load through actions/cache (which is often barely faster than pulling).

RunsOn solves this with extras=ecr-pull-through without you having to change your FROM line.
AWS ECR has a pull-through cache rule where on the first request ECR fetches the image from Docker Hub and keeps a copy. The RunsOn agent then sets up Docker and BuildKit to use the agent’s /v2 endpoint as a registry mirror so the next pull comes from ECR in your region instead of Docker Hub.

9. Build Docker images#
Building a Docker image is a bit different because each instruction in your Dockerfile is a layer which BuildKit only reuses when that instruction and everything above it are unchanged.
Since those intermediate layers don’t exist in a fresh CI runner, they have to be exported at the end of a build and imported at the start of a new build - a mechanism BuildKit supports natively on GitHub via type=gha or type=registry to store it in a separate registry.

With extras=ecr-cache on RunsOn, the agent sets up ECR to be your registry that works out of the box:
runs-on: runs-on=${{ github.run_id }}/runner=4cpu-linux-x64/extras=ecr-cachesteps: - uses: actions/checkout@v7 - uses: docker/setup-buildx-action@v4 - uses: docker/build-push-action@v7 with: push: true tags: ${{ env.RUNS_ON_ECR_CACHE }}:my-app cache-from: type=registry,ref=${{ env.RUNS_ON_ECR_CACHE }}:my-app-cache cache-to: type=registry,ref=${{ env.RUNS_ON_ECR_CACHE }}:my-app-cache,mode=maxAnd if you’re already using type=gha, Magic Cache serves it from your S3 cache bucket without any change:
runs-on: runs-on=${{ github.run_id }}/runner=4cpu-linux-x64/extras=s3-cachesteps: - uses: actions/checkout@v7 - uses: docker/setup-buildx-action@v4 - uses: docker/build-push-action@v7 with: push: false tags: my-app:ci cache-from: type=gha cache-to: type=gha,mode=maxWhichever backend you choose, ordering the Dockerfile well matters as much as the cache does: things that rarely change (system packages, dependency installs) go first, and COPY . . goes last.

Each step needs its own cache#
Now you can see how differently each of these steps behaves.
Some are downloads of things that already exist somewhere far away (the runner, actions, git objects, packages, base images), where the cache is a nearby copy, and the hard part is trusting it.
Others are computations that happen inside the run itself (builds, tests, image layers), where the cache stores earlier results, and the hard part is knowing when a result is still valid, and moving large outputs between machines.
So each step needs a slightly different approach.
As of v3.6, RunsOn covers every one of them, on your own AWS infrastructure, with one label (plus the runs-on/action step from step 6 for build tools):
runs-on: runs-on=${{ github.run_id }}/runner=4cpu-linux-x64/extras=s3-cache+git-cache+apt-cache+ecr-pull-through+ecr-cache