Basic Caching
Reduce cost and latency by caching Stagehand actions across runs
TypeScript
Source codenpx create-browser-app --template basic-caching
Python
Source codeuvx create-browser-app --template basic-caching
Get started with Stagehand action caching
This template demonstrates Stagehand's caching feature by running the same Stripe Checkout workflow twice and comparing performance and cost. The first run executes actions normally (LLM calls), while the cached run reuses stored action results (cache hits) for near-instant execution and $0 additional LLM cost. It also shows how to configure a cache directory and inspect cache entries on disk.
Steps
- Run the workflow once without caching to establish a baseline
- Enable caching and set a cache directory to persist action results across runs
- Repeat the same workflow to populate the cache (first cached run)
- Run the script again to demonstrate cache hits (0 LLM calls, faster execution)
- Inspect the cache directory to see cached action entries