> ## Documentation Index
> Fetch the complete documentation index at: https://docs.blacksmith.sh/llms.txt
> Use this file to discover all available pages before exploring further.

# Turborepo Build Caching

> Blacksmith transparently caches your Turborepo task outputs across runs

## Overview

Blacksmith natively and transparently caches your Turborepo outputs. The cache stores the files each task produces, and a later job restores them when the inputs match. Those tasks do not run again, so the build finishes sooner. No workflow change is required.

## How it works

A task's hash covers the files it reads, the environment variables Turborepo includes, and its configuration in `turbo.json`. Blacksmith stores the outputs under that hash. A job that produces the same hash restores the outputs instead of running the task, including a job on another branch.

Each repository has its own cache, shared across branches and pull requests, so merging to `main` warms the cache for every branch that follows. Caches are separated by CPU architecture and never shared across repositories or organizations.

## Enable Turborepo build caching

Turborepo build caching is on by default for new organizations. An organization admin can turn it on or off from [**Settings > Caching**](https://app.blacksmith.sh/settings/caching) in the Blacksmith dashboard, under **Build systems**. The switch is **Turborepo build cache**.

![An admin turning on Turborepo build cache in Settings > Caching](https://mintcdn.com/blacksmith/MQ-ynRVrOUv23S_z/images/embeds/settings-caching.png?fit=max\&auto=format\&n=MQ-ynRVrOUv23S_z\&q=85\&s=e677f9e566a39b3544a6ffcc7bf8c1a6)

**An admin turning on Turborepo build cache in Settings > Caching**

### Existing remote caches

If a job already sets `TURBO_API`, `TURBO_TOKEN`, or `TURBO_TEAM`, Blacksmith leaves that configuration in place. Remove those variables to use this cache instead. `--no-cache` and `--remote-only` still follow the Turborepo CLI.

## Branch protection

Build cache branch protection is available in [**Settings > Caching**](https://app.blacksmith.sh/settings/caching), under **Dependencies**. When enabled, only jobs running on the default branch (`push`, `schedule`, `workflow_dispatch`) or in a merge queue can write to the cache. Every other job gets read-only access. The setting is off by default and applies to every build cache at once.

Fork pull requests get no Turborepo remote cache at all, regardless of this switch.

## Task outputs

> [!WARNING]
>
> A hit restores only the files named in `outputs` for that task. If the task writes other files, Turborepo replays the log and skips those files. A later step can then fail looking for a generated client. Every file the task creates belongs in `outputs`.

```json theme={"system"}
{
  "tasks": {
    "build": {
      "outputs": ["dist/**", ".next/**", "!.next/cache/**"]
    }
  }
}
```

Do not list `.next/cache/**`. It changes on every build, and the upload is large for a hash that will not match the next run. Turborepo's guide to [specifying outputs](https://turborepo.dev/docs/crafting-your-repository/caching#specifying-outputs) covers the full rules.

## Limitations

The cache runs on the runner. A job that uses [`container:`](https://docs.github.com/en/actions/using-jobs/running-jobs-in-a-container) cannot reach it, and neither can `turbo` inside `docker build`. The log says `Remote caching disabled`, and the tasks run.

Tasks that depend on external state should stay uncached. A test that reads a database, or anything that depends on the clock, is replayed when the inputs Turborepo can see are unchanged. Set `"cache": false` on those tasks.

## Logs and the Cache page

The job log should contain `Remote caching enabled`. Tasks that matched print `cache hit, replaying logs`. A run where every task hit prints `FULL TURBO`. For the full picture, open the [Cache page](https://app.blacksmith.sh/cache), choose a repository, and open the **Turborepo** tab.

![Opening the Turborepo tab on a repository's Cache page to see hit rate, transfers, build duration and recent jobs](https://mintcdn.com/blacksmith/qXGgMwrQ3nf-E1Tw/images/embeds/cache-turbo-tab.png?fit=max\&auto=format\&n=qXGgMwrQ3nf-E1Tw\&q=85\&s=2e60c0f82b94cb417cc054cce944c96b)

**Opening the Turborepo tab on a repository's Cache page to see hit rate, transfers, build duration and recent jobs**

Hit rate there counts what your runs actually experienced. The first builds populate the cache, so compare hit rate and step durations across later runs.

Blacksmith evicts entries that are no longer read. The same page shows what the repository is storing. Turning **Turborepo build cache** off deletes the organization's Turborepo cache.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.