Browserbase Cache
Browserbase Cache is a managed, server-side caching layer built into the Stagehand API. When you run Stagehand withenv: "BROWSERBASE", every act() call is automatically cached on Browserbase’s servers. Repeated calls with the same inputs return instantly without consuming any LLM tokens. You don’t need to configure anything to start benefiting.
The cache key is generated from the instruction, page content, and options you pass. On a cache hit, the response is returned directly from the server with no LLM inference and no token cost. You can inspect cache behavior via the cacheStatus field returned by act(). Check out the Browserbase blog for more details on how it works under the hood.
Disabling on the Constructor
PassserverCache: false to disable caching for all requests made by that instance:
Disabling per Call
Override the instance setting for a single call by passingserverCache: false in the options:
Inspecting Cache Status
act() returns a cacheStatus field you can use to verify whether a result was served from cache:
Limitations
- The page URL factors in to the cache key. If the action is being made on a page with a dynamic URL, caching may not work as expected. We do filter out certain query parameters like referral trackers and analytics, but we don’t catch everything just yet.
- If the page content or structure changes, the action won’t get a cache
HITand the LLM will be called. The subsequent actions will attempt to hit the resulting cache entry.
Local Cache
Local Cache writes action results to your filesystem so they persist across script runs. It works in bothLOCAL and BROWSERBASE environments. When you specify a cacheDir, Stagehand saves every action and agent step to a local file on first run, then replays those cached actions on subsequent runs with no LLM calls, no token cost, and no network round-trip to Browserbase.
This is especially useful for:
- CI/CD pipelines - commit your cache directory to version control for consistent, deterministic runs across environments
- Local development - iterate on automations without burning tokens on repeated runs
- Cross-machine sharing - cache files are portable and can be shared across machines
Caching with act()
Cache actions from act() by specifying a cache directory in your Stagehand constructor.
Caching with agent()
Cache agent actions (including Computer Use Agent actions) the same way. Just specify a cacheDir. The cache key is automatically generated based on the instruction, start URL, agent execution options, and agent configuration. Subsequent runs with the same parameters will reuse cached actions.
Cache Directory Organization
You can organize your caches by using different directory names for different workflows:Best Practices
Use descriptive cache directories
Use descriptive cache directories
Organize caches by workflow or feature for easier management:
Clear cache when DOM changes
Clear cache when DOM changes
If the website structure changes significantly, clear your cache directory to force fresh inference:Or programmatically:
Commit cache for CI/CD
Commit cache for CI/CD
Consider committing your cache directory to version control for consistent behavior across environments:This ensures your CI/CD pipelines use the same cached actions without needing to run inference on first execution.

