(deforum) Cache Image
Stash a frame in the pack's cache so another part of the graph can grab it
- image
- IMAGE
ComfyUI graphs pass data along wires, but not everything you want to share is conveniently on the same path. (deforum) Cache Image gives you a side channel: it takes an IMAGE, tucks a copy into the pack's global cache under a numbered slot, and passes the image through unchanged. A matching (deforum) Get Cached Image node elsewhere in the graph can then pull that stored frame out by the same slot number - no long wire threading across the canvas. It's the pack's answer to "I need this frame over there, but routing the wire would be a mess."
How it works
The node keeps a module-level dictionary of cached images keyed by an integer cache_index (0–16). When it runs, it stores a detached clone of the image tensor under that slot and returns the original. Because the cache lives in the pack's global state, it survives across executions within a session - which is both the point and the thing to watch. The cached image is not written to disk; it's in-memory, so it disappears when ComfyUI restarts.
The slot-numbering is your responsibility. Slot 0 is the default, and there are 17 slots total (0–16). If two different Cache nodes write to the same index, the later one wins - which is either a feature (overwriting a sample you're updating each frame) or a bug (silent clobbering) depending on your intent.
The inputs and outputs
image- theIMAGEyou want to stash.cache_index- which slot to use, 0–16.IMAGE- output, a pass-through of the input image.
Pair it with DeforumGetCachedImageNode (the "Get Cached Image" node) on the receiving side, using the same index.
When it's worth it
The canonical use in Deforum graphs: you generate a reference frame early in the pipeline and want to reuse it later for color matching, as a ControlNet input, or as an img2img base - without dragging a wire across the entire canvas. The cache is also handy when a node's output would be annoying to route because it sits in a different execution branch. That said, be honest about whether you need it: for a single use, a plain wire is simpler and more legible, and ComfyUI workflows are already hard to read. Reach for the cache when the graph genuinely gets cleaner - two nodes and a matching index beat a spaghetti wire.
Installing it
Part of Deforum Nodes (XmYx). ComfyUI Manager → "Deforum Nodes", or:
cd ComfyUI/custom_nodes
git clone https://github.com/XmYx/deforum-comfy-nodes.git
Restart and let first-boot install.py finish (opencv-contrib-python, moviepy, numpy<2.0.0, deforum-studio backend, etc.). Python 3.10 per the README.
Where people get burned
Index collisions are the classic failure: you stash under 0 in one place, another node silently overwrites slot 0, and the receiving node hands you the wrong frame with no error. Name your slots deliberately and keep a mental map. Second: because it's session-global, a stale frame from a previous run can sit in the cache and get picked up if you forget the slot is filled - if your "reference" suddenly looks like an old render, clear the cache or bump the index. And remember the cache is RAM, not disk; huge frames in all 17 slots is memory you're carrying around for nothing.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| cache_index | INT | 00–16 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| IMAGE | IMAGE | — |