Skip to content

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.

nsin-dump-cache.sh

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

It needs only python3, which macOS and every mainstream Linux already ship. Nothing to install, no packages.

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

Terminal window
export NSIN_API_KEY="nsin_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"

A read-only key is enough — the script only reads. See API keys for more.

Terminal window
# 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
# Images only, into a chosen folder, 12 at a time
./nsin-dump-cache.sh example.com --images --out ~/backup -j 12

While 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
1190 unique URLs, 1190 objects to fetch
✓ example.com/assets/hero.webp 184.2 KB · hit
✓ example.com/assets/app.4f2c.js 92.7 KB · hit
████████████████▍ example.com
58% 690/1190 ↓684 ✗6 214.6 MB · 5.1 MB/s ETA 01:24

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.png never overwrite each other.
  • Addresses with no file extension are named from what the server actually returns — /media/8412 served as a WebP is saved as 8412.webp.
  • When the same address is cached with different query strings (/search?q=a and /search?q=b), each gets a short suffix so both are kept: search~e244bbd4.html, search~a96c6999.html.
FlagEnvironment variableWhat it does
--images, -iIMAGES=1Only images. The default takes everything cached.
--out DIR, -oOUTDIRWhere to write. Defaults to the current folder.
-j NCONCURRENCYHow many downloads at once. Default 8.
-kINSECURE=1Skip HTTPS certificate checks.
-hShow help.
NSIN_API_KEYRequired. Your API key.
NSIN_APIAPI base URL. Defaults to https://api.nsin.ir.

The script does two things:

  1. Asks the API which objects are cached for your domain — the same list the panel’s Cached items table shows, paged through in full.
  2. Downloads each of those addresses over HTTPS and writes it to disk.

That second step is a normal request to your site, so anything still cached is served straight from the nearest nsin location. Each finished line shows hit when it came from the cache, and the summary counts them:

done example.com 1184 saved · 0 skipped · 6 failed · 412.9 MB · 1173 edge hits

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.

Some files failed with HTTP 404. Those entries were still listed in the cache but the address no longer exists on your server. Purged or expired items behave the same way.

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. Anything never requested through nsin was never cached and won’t appear.