Clear Cache
Controlled node
Overview
The Clear Cache node clears the internal cache of the workflow. This is useful for forcing nodes that use caching (such as AI Write) to re-run and generate fresh outputs rather than returning previously cached results.
By default, nodes like AI Write cache their outputs based on input parameters to avoid unnecessary recomputation. However, there are cases where you want to ensure fresh generation—such as when using randomized outputs or when the underlying data has changed externally. This node allows you to programmatically clear the cache during workflow execution.
When to use Clear Cache
- Force fresh AI generation: When you want AI Write nodes to produce new content even when inputs haven't changed
- Reset cached data: When external data sources have been updated and cached results are stale
- Debugging: To ensure nodes run fresh during testing and development
Clear Cache clears the cache for the entire workflow, affecting all nodes that store cached data. It does not clear caches for other workflows or global caches.
Inputs
| Input | Type | Description | Default |
|---|---|---|---|
| Run | Event | Fires when the node starts running | - |
Outputs
| Output | Type | Description |
|---|---|---|
| Done | Event | Fires when the cache has been cleared |
Runtime Behavior
When triggered by the Run event, this node immediately calls rootWorkflow.clearCache(), which removes all cached data stored by nodes in the current workflow execution context.
After the cache is cleared, the Done event fires, allowing you to chain subsequent nodes that will now execute without relying on any previously cached results.
Clearing the cache forces computationally expensive nodes (like AI Write or Read Webpage) to re-execute on their next run, which may increase token costs and execution time. Use this node judiciously in production workflows.
Example
Forcing Fresh AI Generation
In this example, the Clear Cache node ensures that an AI Write node generates fresh content even when the prompt hasn't changed:
- Start node triggers the workflow
- Clear Cache node clears any existing cached results from previous runs
- AI Write node generates new text (rather than returning cached output from a previous run with the same prompt)
- Show node displays the fresh output
This pattern is particularly useful when:
- Using the Randomize Output option on AI Write nodes
- Running workflows in loops where you want unique outputs each iteration
- Testing and debugging to ensure nodes are executing fresh rather than pulling from cache
graph TD
A[Start] --> B[Clear Cache]
B --> C[AI Write]
C --> D[Show]