ComfyUI Cache Management: Clear Cache Strategies and Practical Guidance

ComfyUI is aggressive about caching. It keeps models resident, holds node outputs so it can skip re-running unchanged branches, and generally hoards memory to stay fast. Ninety percent of the time that's exactly what you want. The other ten percent - a long batch that creeps toward an out-of-memory crash, a workflow chaining several big models, a machine you'd like to hand back to something else afterward - you want a button that says let go of all of it right now. It forcibly clears ComfyUI's cached memory usage: the node-output cache and the model cache both.

Here's the thing that trips people up about "utility" nodes in a graph: a node only runs when something downstream needs its output. A cache-clear node with no connections is a node ComfyUI can skip. So clearCacheAll is built as a pass-through - it takes one input, anything, and hands it straight back out as output. You don't bolt it on the side; you splice it into a wire. That means the placement is the whole design. Wire it between the stage that just finished with a big model and the stage that's about to load the next one, and you get the flush at precisely the moment you have the most to free and haven't yet allocated what's next. anything (input, any type) - whatever you want to route through. A latent, an image, a model, a plain string - it doesn't care. No settings, no options.

Clear specific cache entries with easy clearCacheKey

The easy clearCacheKey node is designed to help you manage and optimize your cache by allowing you to clear specific cache entries based on a given key. This node is particularly useful when you need to free up memory or ensure that outdated or unnecessary data is removed from the cache. By providing a straightforward method to target and clear specific cache entries, this node helps maintain the efficiency and performance of your system.

This parameter acts as a placeholder and is always set to *. It is used internally to match any input and does not require any specific value from you. The cache_key parameter specifies the key of the cache entry you wish to clear. By providing the exact key, you can target and remove specific entries from the cache, ensuring that only the relevant data is retained. This parameter accepts a string value, and the default value is *, which means all cache entries will be cleared if no specific key is provided. This optional parameter allows you to specify a unique identifier for the cache entry. It can be useful when you have multiple entries with similar keys but need to distinguish between them. If not provided, the node will operate based on the cache_key alone. Another optional parameter, extra_pnginfo, allows you to include additional metadata or information related to the cache entry. This can be useful for debugging or tracking purposes.

The easy clearCacheKey node does not produce any output parameters. Its primary function is to perform an action (clearing cache entries) rather than generating data or results. Solutions: Ensure that the cache_key you provide matches an existing entry in the cache. Verify that the cache_key is correct and exists in the cache. Ensure that the cache_key and optional parameters (unique_id, extra_pnginfo) are correctly specified.

Clear all cache with easy clearCacheAll

The easy clearCacheAll node is designed to simplify the process of clearing all cached data within the ComfyUI environment. This node is particularly useful for AI artists who frequently work with various models and need to ensure that their workspace remains clean and free of outdated or unnecessary cached data. By using this node, you can easily reset the cache, which helps in maintaining optimal performance and avoiding potential conflicts or errors that may arise from stale data.

This parameter acts as a placeholder and is always set to a wildcard value (*). It does not require any specific input from you and is used internally to trigger the cache clearing process. This optional parameter is used to provide a unique identifier for the operation. While it is not required for the basic functionality of clearing the cache, it can be useful for logging or tracking purposes. If not provided, the node will still function correctly. This optional parameter allows you to include additional metadata or information in the operation. Similar to unique_id, it is not required for the basic cache clearing functionality but can be useful for advanced use cases where additional context or data needs to be associated with the cache clearing operation.

The easy clearCacheAll node does not produce any output parameters. Its sole purpose is to clear the cache, and it does not return any values or data upon completion. Solutions: Ensure that the key you are trying to remove is valid and exists in the cache. Verify that the easy clearCacheAll node is correctly configured and that there are no issues with the underlying cache system.

Cache Cleaner Node: a custom solution for workflow-level control

A custom node designed for ComfyUI, the Cache Cleaner Node enables users to efficiently clear the cache from their workflows. The Cache Cleaner Node serves as a utility within ComfyUI, specifically designed to facilitate the clearing of cache directly from the user's workflow. This tool features a boolean input to trigger cache cleaning, which simplifies the process of cache management. The Cache Cleaner Node includes a mechanism for providing feedback through status messages. By incorporating the Cache Cleaner Node into their workflows, users can significantly improve their control over cache management, leading to enhanced efficiency and quality in their projects.

To maximize effectiveness, this node is typically integrated by restarting ComfyUI after installation and ensuring it is correctly wired into the execution path, so its effect occurs at the moment you need to free memory. Restart guidance: ComfyUI Manager: search ComfyUI Easy Use, install, restart. then install the requirements (install.bat on Windows, otherwise pip install -r ComfyUI-Easy-Use/requirements.txt) and restart.

Practical guidance and caveats

  • Memory buildup in ComfyUI is real, and freeing memory now may incur a reload later when a dropped model is needed again.
  • If it seems to do nothing, check that clearCacheAll is actually in the execution path and wired into the flow; a non-wired clear node will not run.
  • Careful placement matters: insert clearCacheAll between the end of a big-model stage and the start of the next stage to flush the most relevant data.
  • Consider using clearCacheKey to remove outdated or specific entries without clearing the entire cache, especially in workflows with multiple models or datasets.

Troubleshooting and real-user scenarios

Imagine the dreaded moment when your C: drive screams "FULL!" and your ComfyUI workflow grinds to a halt. A similar scenario is the WinError 1455. Clear cache nodes provide a way to reclaim space and avoid such errors, but they must be used with understanding of how ComfyUI caches data and how nodes pass through values. The memory management challenges are real, and selective clearing can help mitigate them without paying the cost of reloading everything from disk.

Additionally, independent research and tools can help optimize cache usage. For example, a read-only Python script to analyze Hugging Face caches and a script to migrate thousands of images between drives can complement runtime cache clearing. These utilities are described in guides and project pages for advanced users who manage large AI workflows.

Cache management diagram for ComfyUI

What is a Browser Cache? How Do I Clear It?

Table: quick reference for cache clearing options

NodePurposeKey parametersOutput
easy clearCacheKeyClear specific cache entries by keycache_key, unique_id, extra_pnginfoNone
easy clearCacheAllClear all cache datawildcard key, optional unique_id, extra_pnginfoNone
Cache Cleaner NodeWorkflow-level cache management with feedbackboolean trigger, status messagesFeedback via status

tags: #comfyui #clear #cache