Nodes/SP-Nodes/SP_CacheAutoLoader
ComfyUI Node

SP_CacheAutoLoader

Memoize an expensive node across queue runs, to memory and disk

By bananasss00·Created 2 years ago·Updated 12 days ago· 20
SP_CacheAutoLoader
  • value
  • value
  • status
keydefault_key
cache_directorysp_node_cache
enabledtrue

If a node in your graph is the slow one - a captioning call, an LLM prompt-generation step, some multi-second preprocessing pass - re-running it on every single queue press because you tweaked an unrelated node downstream gets old fast. SP_CacheAutoLoader exists for exactly that: it caches a value against a key you choose, in memory and on disk, and only actually computes the value when that key hasn't been seen before. The pack's own description is blunt about it: "Auto-caches to memory and disk; computes only if necessary."

How it works

This isn't a wrapper that just remembers the last output - it uses ComfyUI's lazy-evaluation hook for custom nodes. The value input's tooltip spells it out: it "is only evaluated if the key is not found in memory or on disk." That means if key already has a cached hit, whatever's feeding value genuinely never runs for that queue press - the expensive upstream chain gets skipped entirely, not just its result discarded. Memory cache disappears when you restart ComfyUI; the disk copy under cache_directory survives across restarts.

Inputs and outputs

  • key (STRING, default default_key) - the identifier the cache is keyed on. Two nodes with the same key share a cache entry, which is a feature until it's an accident.
  • cache_directory (STRING, default sp_node_cache) - where the disk-backed cache lives.
  • enabled (BOOLEAN, default true) - the kill switch. Set false and the node becomes a pure passthrough with no caching at all, which is the fastest way to force a fresh computation without hunting down and clearing the stored entry.
  • value (optional, any type) - the thing being cached, evaluated lazily.

Outputs: value (mirrors what you cached or retrieved) and status, a string presumably reporting hit/miss - worth watching in the console the first few times to confirm the node's behaving the way you expect.

Installing it

ComfyUI Manager - search "SP-Nodes", install, restart. Manually:

cd ComfyUI/custom_nodes
git clone https://github.com/bananasss00/ComfyUI-SP-Nodes

then restart. This particular node's only real dependency is disk space for whatever you're caching - nothing to download up front.

Common issues & troubleshooting

The cache goes stale and you don't notice. The key is a string you pick, not a hash of your upstream inputs - so if you edit the prompt or settings feeding value, the cache has no idea anything changed and will happily hand back the old result under the same key. If output looks frozen after a tweak that should have changed it, that's almost certainly this. Bump the key, or use the sibling SP_CacheManager node to clear it.

Two cached steps collide. Leaving key at the default default_key on more than one node means they're all reading and writing the same cache slot. Give every cache point in a real workflow its own key - or build one dynamically with SP_CompositeCacheKey rather than hand-typing strings you'll forget to keep unique.

The disk cache isn't where you expect. cache_directory is a relative path by default, which resolves against wherever ComfyUI was launched from. If you're hunting for the cache file on disk and it's not showing up, check the working directory ComfyUI actually started in before assuming the node is broken.

CategorySP-Nodes/cache

Inputs (4)

NameTypeDefaultDescription
keySTRINGdefault_keyThe unique key for the cache entry.
cache_directorySTRINGsp_node_cacheThe directory on disk where the cache file will be stored.
enabledBOOLEANtrueIf False, the node will simply pass the value through without any caching.
valueopt*The value to cache. This is only evaluated if the key is not found in memory or on disk.

Outputs (2)

NameTypeDescription
value*
statusSTRING