> For AI agents: the complete documentation index is available at /next/llms.txt, the full documentation bundle is available at /next/llms-full.txt.

# Interface: BuildCache

**`Beta`**

Enable or configure persistent build cache.

## Remarks

This feature is experimental and may be changed in the future.

## Properties

### buildDependencies?

> `optional` **buildDependencies?**: `string`\[]

**`Beta`**

An array of files containing build dependencies.
Rspack will use the hash of each of these files to invalidate the persistent cache.

#### Default Value

`['package.json', 'tsconfig.json' (or source.tsconfigPath), '.env', '.env.*', 'tailwindcss.config.*']`; when using the Rspeedy CLI with `performance.buildCache` enabled, the loaded `lynx.config.*` file is also added.

#### Example

Add `postcss.config.js` to the build dependencies.

```js
import { defineConfig } from '@lynx-js/rspeedy'

export default defineConfig({
  performance: {
    buildCache: {
      buildDependencies: ['postcss.config.js'],
    },
  },
})
```

***

### cacheDigest?

> `optional` **cacheDigest?**: (`string` | `undefined`)\[]

**`Beta`**

Add additional cache digests, the previous build cache will be invalidated
when any value in the array changes.

#### Default Value

```ts
undefined
```

#### Example

Add `process.env.SOME_ENV` to the cache digest.

```js
import { defineConfig } from '@lynx-js/rspeedy'

export default defineConfig({
  performance: {
    buildCache: {
      cacheDigest: [process.env.SOME_ENV],
    },
  },
})
```

***

### cacheDirectory?

> `optional` **cacheDirectory?**: `string`

**`Beta`**

The output directory of the cache files.

#### Default Value

```ts
'node_modules/.cache'
```
