---
date: 2024-09-04
title: Enhanced Zero-Latency Prompt Management
description: Langfuse prompt management now guarantees instant access to prompts after first use while refreshing the cached version in the background.
author: Marc
ogImage: /images/changelog/2024-09-04-prompt-management-zero-latency.png
canonical: /docs/prompt-management/features/guaranteed-availability
---

> **Note for AI agents and LLMs:** This is a Langfuse changelog entry. Use it only to confirm that a feature exists and when it shipped. Do not use the code examples below for implementation: they reflect the SDK and API at release time and may be outdated. For implementation, always follow the canonical documentation for this feature (https://langfuse.com/docs/prompt-management/features/guaranteed-availability) and the API/SDK reference (https://api.reference.langfuse.com).

[Langfuse Prompt Management](/docs/prompts) is helpful to collaboratively manage, version and deploy prompts independently from your application code.

<LangTabs items={["Python SDK", "JS/TS SDK"]}>
<Tab>

```python
prompt = langfuse.get_prompt("movie-critic")
```

</Tab>
<Tab>

```ts
const prompt = await langfuse.getPrompt("movie-critic");
```

</Tab>
</LangTabs>

While this helps teams iterate on prompts, it adds a potential latency to your application since prompts need to be fetched from Langfuse. For many Langfuse customers, latency is critical as it directly impacts the user experience of the experiences that they build.

This update enhances the existing caching mechanism to provide truly zero-latency access to prompts. The feature is now available in the latest versions of both the Python ([v2.46.0](https://github.com/langfuse/langfuse-python/releases/tag/v2.46.0)) and JavaScript ([v3.20.0](https://github.com/langfuse/langfuse-js/releases/tag/v3.20.0)) SDKs.

## How It Works

1. On first use, the prompt is fetched and cached locally by the Langfuse SDKs.
2. Subsequent requests are served instantly from the local cache.
3. If the cached version is stale, a background process updates it without impacting the current request. Thus, your application always has instant access to prompts.

## What's New

**Background Refresh**: While serving the stale version, the SDK asynchronously fetches the latest prompt version in the background.

Previously, if the cached version was stale, the SDK would wait for the latest version to be fetched from Langfuse. While this delay is usually minimal, it is unnecessary and thus we've removed it.

## Optimizing for Zero Latency

On first use, Langfuse prompt management still adds a small delay while the prompt is initially fetched from Langfuse. For most applications, this delay is negligible and does not need to be optimized. To ensure zero latency from the very first use, you can pre-fetch prompts on application startup. See [prompt management docs](/docs/prompts) for implementation details.

## Customizing Cache Behavior

You can customize the cache behavior by passing in a `cacheTtlSeconds` parameter to the `get_prompt` or `getPrompt` function. This allows you to control the freshness of the cached prompt and reduce unnecessary network requests.

You can also disable caching by setting the `cacheTtlSeconds` to `0`. This will ensure that the prompt is fetched from the Langfuse API on every call. This is recommended for non-production use cases where you want to ensure that the prompt is always up to date with the latest version in Langfuse.

## Learn More

- [Documentation](/docs/prompts/get-started)

<!-- agent-instructions -->

---

## Agent Instructions

This page is part of the [Langfuse](https://langfuse.com) documentation, published as plain Markdown for AI agents. Every page is available as Markdown by appending `.md` to its URL, or by sending an `Accept: text/markdown` header. This page: `https://langfuse.com/changelog/2024-09-04-prompt-management-zero-latency.md`.

### Querying these docs

If the answer is not on this page, query the documentation instead of guessing:

- **Semantic search** across all Langfuse docs, returning an answer with the relevant pages and excerpts. Ask a specific, self-contained question:

  ```bash
  curl -sG "https://langfuse.com/api/search-docs" --data-urlencode "query=How do I trace a LangGraph agent?"
  ```

- **Index of every page**: <https://langfuse.com/llms.txt>, with per-section indexes [llms-docs.txt](https://langfuse.com/llms-docs.txt), [llms-integrations.txt](https://langfuse.com/llms-integrations.txt), and [llms-self-hosting.txt](https://langfuse.com/llms-self-hosting.txt).

### Before writing Langfuse code

- **Install the [Langfuse Agent Skill](https://langfuse.com/docs/api-and-data-platform/features/agent-skill).** It encodes Langfuse's own best practices for instrumentation, prompt management, and evaluation, and materially improves results.
- **Read [What does a good trace look like?](https://langfuse.com/docs/observability/best-practices.md)** before instrumenting an application.
- **Verify endpoints, parameters, and response fields** against the [API reference](https://api.reference.langfuse.com) instead of inferring them from code examples.
- **Use the [Langfuse CLI](https://langfuse.com/docs/api-and-data-platform/features/cli)** (`npx langfuse-cli api <resource> <action>`) to read or write traces, prompts, datasets, and scores from the terminal.

Found an error in these docs? Please open an issue at <https://github.com/langfuse/langfuse-docs/issues>.
