Skip to content

The Actions cache

actions/cache works unmodified and is included. What a job may read and write, and the two eviction policies.

Last updated

actions/cache works unmodified. So do the wrappers built on it — setup-node's cache:, setup-go, setup-python, cache/restore and cache/save. You do not change a workflow to use ours and you do not point it anywhere: a Linux job running on our runners resolves the cache service to us, and so does a Windows job.

A Windows job is served by our cache too. A save and a restore on a Windows Server 2025 job and on a Windows Server 2022 job each hit the cache at cache.runners.io (checked with a real job on each image). The route differs from Linux in one way: the job's certificate authority goes into the machine's certificate store, because the Windows runner reads that store and ignores NODE_EXTRA_CA_CERTS (see below). A job whose interception cannot be set up falls back to GitHub's cache, so the cache is GitHub's for that job and not ours.

yaml
jobs:
  build:
    runs-on: runnersio-4vcpu-ubuntu-2404
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: 22
          cache: npm
      - run: npm ci

The Actions cache is included. It is not metered and does not appear as a line on your bill.

This is what happens inside the job's machine, stated exactly, because it involves a certificate you did not install.

Inside a job on our runners, Linux or Windows, the name of GitHub's results service (results-receiver.actions.githubusercontent.com) points at a proxy that serves the job, and the job trusts a certificate authority made for that one name. That is how actions/cache reaches the cache above without a change to your workflow. Where the proxy and the authority live depends on the machine the job got:

  • On our own servers the proxy is the server the job runs on. Its authority is created per server, limited by its own constraints to that one name, and is replaced at least every ninety days. It cannot be used for any other site.

  • On a Windows or ARM job's machine, and on any machine that is not one of our own servers, the proxy runs inside the job's own machine. Its authority is generated there for that one job and is gone when the machine is destroyed or rebuilt at the end of the job, so no authority outlives the job it was made for.

  • The cache calls are answered by us. For these calls the runner's GitHub token is removed before the request reaches the cache (where the proxy runs inside the job's machine, the job's own cache credential takes its place). The cache does not need the GitHub token: it knows which organisation a job belongs to from the credential or the machine the request came from.

  • Everything else on that name goes to GitHub, with the runner's token. Artifact uploads and downloads, step and job logs, and the runner's other results traffic pass through the proxy to GitHub, because that token is what authenticates them there. We do not store that traffic, and the token is not written to any log. On our own servers the access log does keep each request's path, the runner's user agent and timings, for 28 days; a proxy that runs inside the job's machine keeps no access log.

  • No other site is touched. github.com, api.github.com, package registries and your own services keep their own certificates and are not intercepted.

On a Windows job the certificate authority is added to the machine's certificate store (LocalMachine\Root) for the life of the job's machine, which is destroyed when the job ends, and the name is pointed at the job's own proxy through the machine's hosts file. If either step fails, the redirect is abandoned and the job uses GitHub's cache directly.

You can turn this off. An owner or admin can switch it off for the whole organisation under Settings → Runners → Cache settings, in the Actions cache card. It is on by default. With it off, our cache is not used for your jobs: actions/cache goes to GitHub, with GitHub's storage limits and GitHub's speed, and the name above is not redirected in your jobs. The change reaches new jobs within about two minutes. Your Docker layer cache is a separate feature and is not affected.

Entries are partitioned by organisation, repository and git ref. The rules follow the ones GitHub documents, with one difference noted below:

  • A restore looks in two places, in order: the ref the job is running on, then the default branch. The first hit wins, and a job on the default branch does not scan it twice. Unlike GitHub, a pull request's job does not read its base branch's entries, only its own and the default branch's.

  • A save writes to one place: the job's own ref, and never anywhere else. That is what stops a feature branch replacing the entry main depends on.

  • Sibling branches cannot see each other. A cache written on feature-a is not visible from feature-c, on GitHub's runners or on ours.

The scope comes from the job's own credentials rather than from anything the workflow sends, so it is not something a step can widen.

Two policies, both mirroring GitHub's:

  • An entry that has not been read for seven days is removed.

  • A repository holding more than 25 GiB is trimmed least-recently-read first, once an hour, whatever its sibling repositories hold. An organisation holding more than 250 GiB across all of its repositories is trimmed the same way over what the per-repository trim left.

Age since creation is deliberately not a policy. An entry a nightly build has restored every day for a year is doing its job, and deleting it because it is old would be the wrong answer.

Deletion uses GitHub's cache API: list, delete by key, and delete by id. It answers with the same JSON and the same status codes. Two things differ.

The request goes to the cache's own address rather than api.github.com. Inside a run: step on our runners, that address is $ACTIONS_RESULTS_URL and the job's cache credential is $ACTIONS_RUNTIME_TOKEN. Both are already set, and you do not need a secret.

yaml
      - name: Delete a hand-off once it has been read
        run: |
          curl --fail-with-body -X DELETE \
            -H "Authorization: Bearer $ACTIONS_RUNTIME_TOKEN" \
            "$ACTIONS_RESULTS_URL/repos/$GITHUB_REPOSITORY/actions/caches?key=my-build-${{ github.run_id }}"

gh cache list and gh cache delete work too, pointed at the same host:

bash
host="${ACTIONS_RESULTS_URL#https://}"
GH_HOST="$host" GH_ENTERPRISE_TOKEN="$ACTIONS_RUNTIME_TOKEN" \
  gh cache delete my-key --repo "$host/$GITHUB_REPOSITORY"

The paths are GitHub's:

  • GET /repos/{owner}/{repo}/actions/caches lists entries. It takes key, ref, sort, direction, per_page and page.

  • DELETE /repos/{owner}/{repo}/actions/caches?key=… deletes by key.

  • DELETE /repos/{owner}/{repo}/actions/caches/{cache_id} deletes by id.

gh also uses the same paths under /api/v3.

The second difference is that a job deletes only what it could have saved. A delete follows the same rule as a save: the job's own ref, and nowhere else. On GitHub, a token with actions: write can delete any branch's caches, including the default branch's. On our runners a pull request's job cannot delete main's entries, however it asks:

What it asks forAnswer
by key, no refthat key in its own ref only
by key, with ref set to another branch403, naming the ref it may delete from
by the id of another branch's entry404

The same rules hold for every other case:

  • A run on the default branch that GitHub treats as read-only there (pull_request_target, issue_comment, workflow_run) cannot delete anything.

  • Another repository's or organisation's path answers 404.

  • A GitHub token is refused with 401. Only the job's own cache credential is accepted.

A listing shows what the job could restore: its own ref, then the default branch.

A delete in a job's first few seconds can be answered 403 with "the build running in this runner is not yet known". The scope comes from the job GitHub actually gave the runner, and GitHub tells us that a moment after the job starts. Retry after a few seconds. A save never meets this, because it happens at the end of a job.

A restore that is already downloading an entry when it is deleted normally finishes: its download was opened before the delete and is not cut. A download that starts after the delete, including each further range a client asks for, is refused with a 404, and that restore fails. Delete an entry only once its readers have finished with it.

It is a per-organisation switch, and it is off until an owner turns it on. In Settings → Runners → Cache settings, the Build caches card has one checkbox, "Use our cache for Turborepo and Bazel". It is one switch for both tools, kept per organisation and never shared with another. Only an owner or admin can change it. A change reaches new jobs within about two minutes; turning it off stops new jobs being pointed at our cache, and Turborepo and Bazel then behave as they did before. Until it is on, a Turborepo run on our runners uses whatever remote cache you configure yourself, or none.

Turborepo can keep each task's output in a remote cache, keyed by a hash it computes from the task's inputs. When the switch is on, a Linux job on our runners gets that cache with no workflow change: the runner sets TURBO_API, TURBO_TOKEN and TURBO_TEAM for the job, and turbo run build restores a task it has built before instead of running it. The second run of an unchanged monorepo reports FULL TURBO.

It is stored as ordinary Actions-cache entries, so it follows the rules above and adds none:

  • Scopes. A job reads its own branch's artifacts, then the default branch's. It writes only the branch it is running on. A pull request's build can never write the default branch's artifacts, and never reads a sibling branch's. Your organisation and repository are taken from the job's own credential, not from TURBO_TEAM, which we ignore: setting it to another name reaches nothing.

  • Pull requests from forks restore from the default branch and save nothing. So do runs on the default branch started by pull_request_target, workflow_run or issue_comment, as for any cache entry.

  • Limits and eviction. The Actions cache's limits: 25 GiB for a repository and 250 GiB for an organisation, least recently read removed first, and an entry not read for 7 days removed. One artifact may be up to 1 GiB; a larger one is accepted and dropped, never an error, so a task that produces it still passes and runs again next time.

  • Failure never fails a build. If the cache is unreachable, refuses a save or has nothing for a hash, Turborepo builds the task as it would without one.

  • Price. It is part of the Actions cache. There is no separate charge and no line for it on your invoice.

What is stored is what your task lists in outputs. We cannot look inside the archive Turborepo uploads. Do not list .env files, credential files or key material in a task's outputs: anything listed is saved to the cache and restored into later builds of this repository, including by other branches that may read it.

Your own TURBO_API, TURBO_TOKEN or TURBO_TEAM, set in a job's or step's env:, take the place of ours. If you already use Vercel's remote cache, leave the switch off for your organisation: with it on, setting only TURBO_TOKEN and TURBO_TEAM would send your Vercel token to the address we set for TURBO_API, and your builds would stop using Vercel's cache. The switch is per organisation, not per repository.

Bazel is the other way round. The same switch gives your jobs a system-wide --remote_cache and a --remote_header carrying the job's cache token. If your own .bazelrc names a different --remote_cache, yours wins the address and Bazel still sends that cache the job's cache token as well. Leave the switch off unless you want Turborepo and Bazel to use ours.

Cache in the dashboard shows the hit rate for the period, storage used, and how many entries there are. If you are over the storage ceiling it says so, rather than silently dropping things.

A hit rate that falls is almost always a key that has started varying when it should not — a lockfile hash that includes a timestamp, or a matrix dimension that has crept into the key. The entry list is where that shows up: one key has quietly become hundreds.

This is the Actions cache: a keyed archive your workflow restores and saves explicitly. It is not the Docker layer cache, which is a different mechanism for a different problem — see the Docker layer cache.