Sites
A site is a static website stored on IOTA Storage, indexed by an object in your IOTA wallet and reachable through a subdomain or an IOTA Names name.
- Files. Each file of the site is a patch of a quilt: a blob owned by you and paid in IOTA, like any other.
- Index. A
Siteobject in your wallet (packagesitios) has oneResourceper path, with the file's HTTP headers, the blob ID of its quilt, the patch (x-quilt-patch-internal-idheader) and its SHA-256. - Configuration. An optional
ws-resources.jsonfile in the site folder sets headers, routes, redirects, the site name and its metadata.
You publish and manage sites with the app or with the reference CLI.
How a site is served
The portal serves every Site of the sitios package at two kinds of address:
| Address | Example |
|---|---|
https://<site ID in base36>.iotastorage.com/<path> | The Site ID 0x… written in base36. |
https://<name>.iotastorage.com/<path> | https://blog.alice.iotastorage.com/ serves the site that the IOTA Names name blog.alice.iota points to. See IOTA Names. |
The base36 form is the 32 bytes of the object ID written in base 36 (each leading zero byte is a
0). The app shows the URL of each site, and the CLI converts in both directions with
node sitio.mjs convertir.
How the portal resolves a path
For each request, the portal reads the Site and the resource of the path from IOTA, in a single
query, and then tries, in this order:
- The resource of the path.
/is/index.html, and a trailing slash is removed. <path>/index.html, if the path has no extension. So/docs/and/docsserve/docs/index.html.- A redirect of the site that matches the path: answers with its status (301, 302, 303, 307 or
308) and a
Locationheader. - A route of the site that matches the path: serves the resource it points to.
- The site's
/404.html, with status 404. - Otherwise, the portal's own "Page not found" page, with status 404.
The bytes come from the aggregator: the patch of the quilt, by its quilt patch ID. Before serving
them, the portal checks that their SHA-256 is the one the Site declares on IOTA.
Responses
A served resource carries the headers stored in its Resource (headers that are not valid in HTTP
are not sent), plus:
x-resource-iota-object-idandx-resource-iota-object-version: the dynamic field that holds the resource;x-sitio-iota: the ID of theSite.
The portal only answers GET and HEAD. Errors:
| Status | When |
|---|---|
| 400 | The address or the path is not valid. |
| 404 | No site at that address; the name does not exist, expired or does not point to a site; the page does not exist; or the data of the file is no longer available (it expired). |
| 405 | A method other than GET or HEAD. |
| 422 | The bytes do not have the SHA-256 that the site declares on IOTA. |
| 503 | The IOTA node or the aggregator did not respond. Try again later. |
| 508 | A redirect of the site points to the same path. |
Quilts and costs
- The files to upload are grouped in quilts, from smallest to largest. With 100 shards a quilt holds up to 66 files. Since this network has few columns per quilt, a quilt larger than 1 MiB that would be more than 4 times the size of its files is split in two.
- Each resource is a dynamic field of the
Sitewith its storage deposit: about 0.005 IOTA per file, almost all of it deposit, which comes back to you when you destroy the site. - On testnet, the example site of the project (6 files) costs about 0.035 IOTA to publish, almost all of it deposit, plus a few thousand nanos of storage.
Expiration
A site is available as long as the blobs of its files are. Each purchase covers at most 53 epochs (53 days on testnet). Renew the site before it expires: see Update, renew and destroy. When a file has expired, the portal answers 404 with a page that says the content is no longer available.