nsindocs Search the docs⌘K
  1. Docs
  2. Caching

Downloading Your Cached Files

Download everything nsin has cached for a domain, straight from cache storage, with the nsin-dump-cache.sh script.

On this page

The Cached items list shows what's stored. nsin-dump-cache.sh downloads the files from your terminal, one folder per domain, keeping paths and filenames.

Files come straight from cache storage, not your site, so a dead origin makes no difference.

Download the script

nsin-dump-cache.sh

bash
curl -o nsin-dump-cache.sh https://nsin.ir/docs/nsin-dump-cache.sh
chmod +x nsin-dump-cache.sh

Needs only python3 — already on macOS and most Linux.

Set your API key

Create a key at panel.nsin.ir → Settings → API Keys and export it:

bash
export NSIN_API_KEY="nsin_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"

A read-only key is enough. See API keys.

Run it

bash
# One domain (at least one is required)
./nsin-dump-cache.sh example.com

# Several at once — each gets its own folder
./nsin-dump-cache.sh example.com shop.example.com example.ir

# A different edge location, images only, into a chosen folder, 12 at a time
./nsin-dump-cache.sh example.com --node TH --images --out ~/backup -j 12

Live progress per domain: objects done, bytes, speed, and ETA.

text
▶ example.com
  registry: 1284 cached entries at node IR
  1190 unique URLs, 1190 objects to fetch
  ✓ example.com/assets/hero.webp       184.2 KB
  ✓ example.com/assets/app.4f2c.js      92.7 KB
  ⊙ example.com/old/banner.png         no longer cached
  ████████████████▍            example.com
     58% 690/1190  ↓684  ⊙6   214.6 MB · 5.1 MB/s  ETA 01:24

Choosing an edge location

Your site caches separately per nsin location; --node picks which copy to download:

bash
./nsin-dump-cache.sh example.com              # IR, the default
./nsin-dump-cache.sh example.com --node TH
./nsin-dump-cache.sh example.com --node any   # whichever copy is listed first

Node names match Cached items, case-sensitive; an empty location lists the ones that aren't:

text
nothing at node NY.  cached at: IR (1284), TH (233)

--node any gives the widest coverage, pulling whichever copy exists.

Where the files go

Files land under the current folder (or --out), one folder per domain:

text
example.com/
├── index.html
├── assets/
│   ├── hero.webp
│   └── app.4f2c.js
└── cdn.example.com/          ← other hostnames get their own subfolder
    └── logo.png
  • Subdomains and wildcards get their own subfolder — no /logo.png collisions.
  • No-extension files are named by content type — /media/8412 as WebP saves as 8412.webp.
  • Different query strings on one address (/search?q=a, /search?q=b) get a suffix per copy: search~e244bbd4.html, search~a96c6999.html.
  • Files come out uncompressed, as stored, even if gzipped for visitors.

Options

Flag Environment variable What it does
--node NAME, -n NSIN_NODE Which location's copy to take. Default IR; any takes whatever's listed.
--images, -i IMAGES=1 Only images; default takes everything.
--out DIR, -o OUTDIR Where to write. Default: current folder.
-j N CONCURRENCY How many downloads at once. Default 8.
-k INSECURE=1 Skip HTTPS certificate checks.
-h — Show help.
— NSIN_API_KEY Required. Your API key.
— NSIN_API API base URL; default https://api.nsin.ir.

How it works

Two API calls per object, both to api.nsin.ir:

  1. List — GET /domains/<domain>/cache/keys, paged and filtered to the node. Same data as the panel's Cached items table.
  2. Download — GET /domains/<domain>/cache/keys/content per row, returning that entry's stored bytes.

Each entry is keyed by hostname, node and key_hash. Nothing touches your site: no DNS, no edge request, no server request.

Common questions

It says "not found, or this key's user has no access". Spell the domain exactly as your panel shows it — the key's account must own, or have been shared, that domain.

I get far fewer files than the panel's item count. The panel's count covers every location; a --node run only takes that location's copies. Try --node any.

Can I use it to migrate a site? You get cached, public files — useful, not a backup. Login-only, uncached, or unvisited pages were never stored.

esc