# Prompt Caching

> Learn how prompt caching can reduce processing time and costs for repetitive LLM prompts, with details on configuration and provider support including OpenAI and Anthropic.

Prompt caching is a feature that can reduce processing time and costs for repetitive prompts. It is supported by various LLM providers, but the implementation may vary.

## `ephemeral`

[Section titled “ephemeral”](#ephemeral)

You can mark `def` section or `$` function with `cacheControl` set as `"ephemeral"` to enable prompt caching optimization. This essentially means that it is acceptable for the LLM provider to cache the prompt for a short amount of time.

```js
def("FILE", env.files, { cacheControl: "ephemeral" })
```

```js
$`Some very cool prompt`.cacheControl("ephemeral")
```

## LLM provider support

[Section titled “LLM provider support”](#llm-provider-support)

In most cases, the `ephemeral` hint is ignored by LLM providers. However, the following are supported

### OpenAI, Azure OpenAI

[Section titled “OpenAI, Azure OpenAI”](#openai-azure-openai)

[Prompt caching](https://platform.openai.com/docs/guides/prompt-caching) of the prompt prefix is automatically enabled by OpenAI. All ephemeral annotations are removed.

* [OpenAI Documentation](https://openai.com/index/api-prompt-caching/).

### Anthropic

[Section titled “Anthropic”](#anthropic)

The `ephemeral` annotation is converted into `'cache-control': { ... }` field in the message object.

Note that prompt caching is still marked as beta and not supported in all models (specially the older ones).

* [Anthropic Documentation](https://docs.anthropic.com/en/docs/build-with-claude/prompt-caching)