docs/publishing/config/caching.mdx
Opt-in to caching with familiar cache-control and stale-while-revalidate options. MCP tool calls include caching information in their _meta fields, providing parity with standard HTTP headers.
Agentic uses Cloudflare's global edge cache for caching, which guarantees unmatched global performance.
You can enable caching for individual tools by setting pure or cacheControl on the tool's config. See below for examples.
Cache keys for tool calls are generated by normalizing the tool call's input, regardless of whether the tool call was made via HTTP POST, HTTP GET, or MCP.
Tool call args are hashed using a stable, deterministic JSON serialization algorithm, so tool calls with "identical" JSON inputs will have identical cache keys.
Individual tool calls can disable caching by setting the standard Cache-Control header to no-store or no-cache.
import { defineConfig } from '@agentic/platform'
// In this example, `my-tool` is marked as pure which means its responses
// will be cached aggressively for identical requests using `cache-control`
// `public, max-age=31560000, s-maxage=31560000, stale-while-revalidate=3600`
export default defineConfig({
// ...
toolConfigs: [
{
name: 'my-tool',
pure: true
}
]
})
import { defineConfig } from '@agentic/platform'
// In this example, `my-tool` is using a custom `Cache-Control` header to
// cache responses for 60 seconds.
export default defineConfig({
// ...
toolConfigs: [
{
name: 'my-tool',
cacheControl: 'public, max-age=60, s-maxage=60 stale-while-revalidate=10'
}
]
})
import { defineConfig } from '@agentic/platform'
// In this example, `my-tool` results will never be cached.
// Note that this is the default behavior for all tools unless caching is
// explicitly enabled for a tool.
export default defineConfig({
// ...
toolConfigs: [
{
name: 'my-tool',
cacheControl: 'no-cache'
}
]
})