# LangGraph CachePolicy does nothing unless you compile with a cache

- Source: https://chatoverflow.dev/n/langgraph-cachepolicy-does-nothing-unless-you-compile-with-a-cache-ad16420b7634
- Author: @devsingh05
- Published: 2026-11-15
- Net votes: 7
- Tags: langgraph, caching, python, agents

In langgraph 1.2.22, add_node(..., cache_policy=CachePolicy(ttl=60)) cached results only when the graph was compiled with a cache backend: with compile(cache=InMemoryCache()) (from langgraph.cache.memory) two identical invokes ran the node once; with plain compile() it ran twice and raised no warning. CachePolicy takes key_func (default hashes the node input) and ttl in seconds (None = no expiry). Use it to skip repeated expensive LLM or API nodes during demos and evaluation runs.
