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

# Sandbox Template Build Caching

> Control template build caching: skip the cache for a whole build with skipCache, from a given layer onward with .skipCache(), or with --no-cache in the CLI.

Template builds cache previously completed layers so repeated builds do not have to rerun every instruction, which speeds up iteration. Skip the cache only when you need to force a fresh build — skipping the cache makes builds significantly slower.

Caching is enabled by default and requires no configuration. When you want to skip the cache and force a rebuild, the SDK and CLI offer three levels of control:

| Scope | Effect | Usage |
| - | - | - |
| Whole build | Ignore all cache and rebuild the entire template from scratch | JS: `novita.template.build(t, name, { skipCache: true })`  Python: `novita.template.build(t, name, skip_cache=True)` |
| From a layer onward | Force **this instruction and all following layers** to rebuild; if placed right on a `from*` (FROM) instruction, the whole template cache is invalidated | JS: `.skipCache()`  Python: `.skip_cache()` |
| CLI | Ignore the cache during a build | `novita template build --no-cache` |

> [!NOTE]
>
> **Important:** The chained methods `skipCache()` / `skip_cache()` do not skip a single instruction only — they apply to **all subsequent layers** from the point they are called. The earlier you place the call, the more of the cache is invalidated.

**Example:** skip the cache in the definition and force a full rebuild (the two approaches can be combined).

```js JavaScript & TypeScript icon="js" theme={"system"}
import { Novita } from 'novita-sandbox'

const novita = new Novita()
const template = novita.template
  .new()
  .fromPythonImage('3.12')
  .skipCache() // no cache for any layer from here on
  .runCmd('pip install -U pip')

const build = await novita.template.build(template, 'my-template-no-cache', {
  skipCache: true, // ignore the cache for the whole template
})
```

```python Python icon="python" theme={"system"}
from novita_sandbox import Novita

novita = Novita()
template = (
    novita.template.new()
    .from_python_image("3.12")
    .skip_cache()  # no cache for any layer from here on
    .run_cmd("pip install -U pip")
)

build = novita.template.build(
    template,
    "my-template-no-cache",
    skip_cache=True,  # ignore the cache for the whole template
)
```


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