Nodes/NH-Nodes/NH Large Preview Cache Manager
ComfyUI Node

NH Large Preview Cache Manager

Your big previews are stacking up in temp. Here's the broom.

By jetthuangai·Created 5 months ago·Updated 21 days ago· 6
NH Large Preview Cache Manager
    • summary
    • removed
    • freed_mb
    • cache_root
    actioninfo
    max_age_hours24.0
    max_total_mb2048
    cache_id

    Every time NH Large Image Preview or NH Large Image Compare runs, it writes a pile of tiles into ComfyUI/temp/nh_large_preview. Run a big batch and that folder quietly turns into gigabytes. NH Large Preview Cache Manager (class NH_LargePreviewCacheManager) is the cleanup node for exactly that: it inspects the cache, deletes by age, enforces a size cap, or nukes one specific cache by id - from inside the graph, no file manager spelunking.

    How it works

    It's an output node that talks directly to the pack's cache helpers. Pick an action, set the thresholds, run it, and it returns a JSON summary of before/after state. The cache root lives under ComfyUI's temp directory (folder_paths.get_temp_directory() / "nh_large_preview"), and the node reports it back on the cache_root output so you know exactly where it's looking.

    The actions

    • info - read-only. Reports how many cached previews exist and how much disk they're using. Run this first before you delete anything.
    • cleanup_by_age - removes caches older than max_age_hours (default 24).
    • enforce_size_limit - keeps the cache under max_total_mb (default 2048), deleting oldest-first.
    • cleanup_age_and_size - both at once.
    • delete_cache_id - remove one specific cache. Requires a cache_id, which you can pull from a preview node's manifest output. The pack validates ids strictly (32-char hex), so you can't fumble a path in here.

    Outputs are summary (the JSON), removed (how many caches deleted), freed_mb, and cache_root. If you're automating, wire removed or freed_mb into a text/logging node to see what happened.

    Installing

    From ComfyUI Manager search NH-Nodes, install, restart. Or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/jetthuangai/NH-Nodes.git
    cd NH-Nodes
    pip install -r requirements.txt
    

    Restart ComfyUI and refresh the browser page. This node only needs the common image libraries from the pack's requirements; the heavier deps (onnxruntime, transformers) belong to its Vision/VTON nodes.

    Where people get burned

    Two gotchas worth knowing. First, this is a temp cache by design - ComfyUI's own temp cleanup can already wipe it, so don't treat the tiles as durable storage. Second, the node needs a workflow run to do its thing, which can feel backwards: you're queueing a "run" just to delete files. That's the standard ComfyUI model for maintenance nodes, but it means you'll want this as a tiny dedicated workflow, not buried in a 400-node production graph. It raises a ValueError if you ask for delete_cache_id without an id, which is a fine footgun to know about before you hit it. Honestly, if your disk isn't complaining, info alone is worth having around just to know what's piling up.

    CategoryNH-Nodes/Image

    Inputs (4)

    NameTypeDefaultDescription
    actionCOMBOinfo5 options: info, cleanup_by_age, enforce_size_limit, cleanup_age_and_size, delete_cache_id
    max_age_hoursFLOAT24.00–8760
    max_total_mbFLOAT20481–1048576
    cache_idSTRING

    Outputs (4)

    NameTypeDescription
    summarySTRING
    removedINT
    freed_mbFLOAT
    cache_rootSTRING