Downloading Your Cached Files
The Cached items list shows you what nsin has stored. Sometimes you want the files themselves — to recover images after a server crash, to inspect what visitors are actually being served, or to keep a snapshot before a big change.
nsin-dump-cache.sh does that from your terminal. Give it one or more domains
and it writes every cached object into a folder per domain, keeping the original
paths and filenames.
The files are read out of nsin’s cache storage, not fetched from your site. Your server is never contacted, so a dead origin — the usual reason you need the cached copies — makes no difference to what you get back.
Download the script
Section titled “Download the script”curl -o nsin-dump-cache.sh https://nsin.ir/docs/nsin-dump-cache.shchmod +x nsin-dump-cache.shIt needs only python3, which macOS and every mainstream Linux already ship.
Nothing to install, no packages.
Set your API key
Section titled “Set your API key”Create a key at panel.nsin.ir → Settings → API Keys and export it:
export NSIN_API_KEY="nsin_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"A read-only key is enough — the script only reads. See API keys for more.
Run it
Section titled “Run it”# 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 12While it runs you get a live progress bar per domain — how many objects are done, how much has been downloaded, the current speed and an ETA — with each finished file listed above it.
▶ 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:24Choosing an edge location
Section titled “Choosing an edge location”Your site is cached separately at each nsin location, so the same URL can exist
as several stored copies. --node picks which one you download:
./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 firstNode names are the ones shown in the Cached items list and in the per-location totals above it, and they are case-sensitive. If the location you picked holds nothing, the script tells you which ones do:
nothing at node NY. cached at: IR (1284), TH (233)--node any gives you the widest coverage — a file cached only at one location
still comes down — at the cost of picking copies from wherever they happen to
live.
Where the files go
Section titled “Where the files go”Files land under the current folder (or --out), one folder per domain:
example.com/├── index.html├── assets/│ ├── hero.webp│ └── app.4f2c.js└── cdn.example.com/ ← other hostnames get their own subfolder └── logo.png- Subdomains and wildcard hostnames are kept in their own subfolder, so two
different
/logo.pngnever overwrite each other. - Addresses with no file extension are named from the stored content type —
/media/8412cached as a WebP is saved as8412.webp. - When the same address is cached with different query strings
(
/search?q=aand/search?q=b), each gets a short suffix so both are kept:search~e244bbd4.html,search~a96c6999.html. - Files come out uncompressed, exactly as nsin stores them, even if visitors receive them gzipped.
Options
Section titled “Options”| Flag | Environment variable | What it does |
|---|---|---|
--node NAME, -n | NSIN_NODE | Which edge location’s copy to take. Default IR; any takes whatever is listed. |
--images, -i | IMAGES=1 | Only images. The default takes everything cached. |
--out DIR, -o | OUTDIR | Where to write. Defaults to the 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. Defaults to https://api.nsin.ir. |
How it works
Section titled “How it works”Two API calls per object, both to api.nsin.ir:
- List —
GET /domains/<domain>/cache/keys, paged through in full, filtered to the chosen node. This is the same data the panel’s Cached items table shows. - Download —
GET /domains/<domain>/cache/keys/contentfor each row, which returns that entry’s stored bytes.
Each entry is addressed by the hostname, node and key_hash from its listing
row — the identity it is stored under. Nothing in this path touches your site: no
DNS lookup for your domain, no request to the edge, no request to your server.
Common questions
Section titled “Common questions”It says “not found, or this key’s user has no access”. The domain name must be spelled exactly as it appears in your panel, and the key must belong to an account that owns — or has been shared — that domain.
I get far fewer files than the panel’s item count.
The count in the panel covers every location. A single --node run only takes
that location’s copies — try --node any.
Can I use it to migrate a site? It gets you the cached, public files — useful, but it is not a backup of your server. Files behind a login, anything marked not to cache, and pages nobody visited were never stored.