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

# sccache integration

sccache is a compiler caching tool that supports C, C++, Rust, and other languages.

Namespace provides high-performance [sccache](https://github.com/mozilla/sccache) caching with
low network latency between runners and the cache storage. Builds reuse compilation
results across runs, reducing build times.

sccache caching is particularly effective for:

* C and C++ projects with long compilation times
* Rust projects where incremental compilation can be slow
* Projects that benefit from sharing compilation artifacts across team members

## Getting started

You can produce a ready-to-use configuration using the [CLI](/docs/reference/cli/installation):

<Steps titleSize="h3">
  <Step title="Configure cache access and start sccache">
    `nsc cache sccache setup` generates short-term credentials from your current `nsc` login and prints the environment variables needed to configure sccache (e.g. `SCCACHE_WEBDAV_ENDPOINT`, `SCCACHE_WEBDAV_TOKEN`) as `KEY=value` lines. Export them into your shell, then start sccache:

    ```bash theme={null}
    export $(nsc cache sccache setup --cache_name default)
    sccache --start-server
    ```

    sccache will now use Namespace's remote cache for all subsequent compilations. These credentials are short-lived, which suits CI runners and an authenticated shell.
  </Step>
</Steps>

### GitHub Actions Example

In GitHub Actions, append the output of `nsc cache sccache setup` to [`$GITHUB_ENV`](https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-commands#setting-an-environment-variable) so the credentials are available in every subsequent step. Setting `RUSTC_WRAPPER: sccache` on the build step makes `cargo` invoke `sccache`, which auto-starts a server using the env from `$GITHUB_ENV`.

```yaml theme={null}
jobs:
  build:
    runs-on: namespace-profile-default
    steps:
      - uses: actions/checkout@v4
      - name: Configure sccache # [!code ++:2]
        run: nsc cache sccache setup --cache_name default >> "$GITHUB_ENV"
      - name: Build
        env: # [!code ++:2]
          RUSTC_WRAPPER: sccache
        run: cargo build
```

## Using from your local workstation

You can use the same sccache cache from your workstation when you don't have an ambient `nsc` login. Since the cache is shared, local builds benefit from artifacts already cached by CI, and vice versa.

<Steps titleSize="h3">
  <Step title="Create a long-term token">
    Create a long-term token with access to the cache. The command saves the token to `token.json` in the current directory:

    ```bash theme={null}
    nsc cache sccache create-token --cache_name default
    ```

    ```text nocopy Output theme={null}
    Token ID:    tok_...
    Name:        sccache-default-n525mfg
    Expires At:  2026-02-13T12:07:43+01:00
    ```
  </Step>

  <Step title="Set up sccache with the token">
    Use the saved token to generate the sccache environment variables:

    ```bash theme={null}
    nsc cache sccache setup --token token.json --cache_name default
    ```
  </Step>

  <Step title="Start sccache">
    Export the generated environment variables, then start the sccache server:

    ```bash theme={null}
    export $(nsc cache sccache setup --token token.json --cache_name default)
    sccache --start-server
    ```

    The credentials are bound to your user. If the user is removed from the workspace (or their permissions are reduced), the token becomes invalid. The token can also be revoked ahead of time.
  </Step>
</Steps>

## How it works

The sccache caching solution provides remote storage for compilation artifacts, where the hot cache lives as close to the consumer (e.g. your CI job runner) as possible.
The cold caching tier is backed by our high-performance [artifact storage](/docs/architecture/storage/artifact-storage), which lets sccache retain a large number of cached artifacts.

Access to the sccache cache is granted through short-lived secure credentials.

## Usage

Namespace accounts sccache cache usage in two categories:

* Artifact cache storage
* Artifact cache reads

For detailed billing information for each item as well as included amounts in your plans,
visit [the pricing page](https://namespace.so/pricing).
