---
source: https://iinventedlight.com/library/notes/hf-hub-cache-management.md
title: "The Hugging Face Hub cache: layout, location, cleanup"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "Apache-2.0 (huggingface/transformers, huggingface_hub, diffusers docs; LICENSE verified in each repo); prose restates cited source lines in own words"
license_family: hf-apache
attribution: "Summary by iinventedlight (AI-assisted). Sources: Hugging Face docs, Understand caching, Apache-2.0 (huggingface docs repos); Hugging Face docs, Environment variables, Apache-2.0 (huggingface docs repos)."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-09
status: published
checked_on: 2026-11-09
as_of: 2026-11-09
confidence: medium
untested: "No code was run for this note; only the fetched documentation pages were read."
category: coding-references
topic_area: "code-ai-eng: Hugging Face"
tags: [hugging-face, huggingface-hub, cache, hf-cli]
client: Librarian
sources:
  - id: S1
    title: "Understand caching"
    publisher: Hugging Face docs
    url: https://huggingface.co/docs/huggingface_hub/guides/manage-cache
    accessed: 2026-11-09
    license: "Apache-2.0 (huggingface docs repos)"
  - id: S2
    title: "Environment variables"
    publisher: Hugging Face docs
    url: https://huggingface.co/docs/huggingface_hub/package_reference/environment_variables
    accessed: 2026-11-09
    license: "Apache-2.0 (huggingface docs repos)"
---
# The Hugging Face Hub cache: layout, location, cleanup

**Answer:** `huggingface_hub` uses a local file-based cache, the central cache shared across libraries that depend on the Hub. The default is `~/.cache/huggingface/hub`, customizable with `HF_HOME` or `HF_HUB_CACHE`. Run `hf cache ls` to explore what is stored locally.

## Layout per repo

- `refs`: files naming the latest revision of each reference; `refs/main` holds the commit identifier of the current head.
- `blobs`: the actual downloaded files, each named by its hash.
- `snapshots`: one folder per known revision, containing symlinks to the blobs.

A file isn't downloaded twice if it already exists and wasn't updated; an updated file is downloaded while the previous file is kept.

## Location variables

- `HF_HOME` defaults to `~/.cache/huggingface`; the token defaults to `$HF_HOME/token`.
- `HF_HUB_CACHE` defaults to `$HF_HOME/hub`.
- `HF_HUB_OFFLINE=1` skips the HTTP check that `hf_hub_download` makes even when the latest file is cached.

## Cleanup

Use `hf cache rm` to permanently delete repositories or revisions; `hf cache prune` removes shared files that no cached repo uses.

## Artifacts

- [Topic packet: huggingface](https://iinventedlight.com/library/packets/huggingface.json)

## See also

- [hf-hub-download-files](https://iinventedlight.com/library/notes/hf-hub-download-files/)
- [hf-datasets-cache](https://iinventedlight.com/library/notes/hf-datasets-cache/)
- [huggingface-hf-cli](https://iinventedlight.com/library/notes/huggingface-hf-cli/)

## Claims

- id: C1
  claim: The Hub cache is shared across libraries.
  source: S1
  evidence: "designed to be the central cache shared across libraries that depend on the Hub."

- id: C2
  claim: Blob files are named by hash.
  source: S1
  evidence: "The name of each file is their hash."

- id: C3
  claim: HF_HUB_CACHE defaults under HF_HOME.
  source: S2
  evidence: "Defaults to `\"$HF_HOME/hub\"` (e.g. `\"~/.cache/huggingface/hub\"` by default)."

- id: C4
  claim: HF_HUB_OFFLINE=1 skips the freshness call.
  source: S2
  evidence: "will skip this call which speeds up your loading time."

- id: C5
  claim: hf cache rm deletes repos or revisions.
  source: S1
  evidence: "to permanently delete repositories or revisions from your cache."

## Sources

- [S1] Understand caching. Hugging Face docs. https://huggingface.co/docs/huggingface_hub/guides/manage-cache . License: Apache-2.0 (huggingface docs repos). Accessed 2026-11-09.

- [S2] Environment variables. Hugging Face docs. https://huggingface.co/docs/huggingface_hub/package_reference/environment_variables . License: Apache-2.0 (huggingface docs repos). Accessed 2026-11-09.


License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: Hugging Face docs (huggingface/transformers, huggingface/huggingface_hub, huggingface/diffusers on GitHub), Apache License 2.0 (https://www.apache.org/licenses/LICENSE-2.0). Text was condensed and changed from the originals.

---

Agents: [/agents.md](/agents.md) | [/.well-known/agent-library.json](/.well-known/agent-library.json).
