# Request IDs and headers

What the platform stamps on responses, and how to use it when something goes wrong.

## The request id

Every response carries:

```
x-pilvia-request-id: 7f3c9a2e5b1d4e08a4c6f0b93d2e7a15
```

The id is minted by the platform for each request, injected into the
request your server code sees (so your own logging can carry it), and
equal to the trace id on every telemetry record the platform keeps about
that request. **When reporting a problem, quote this header** — it turns
"the form didn't work yesterday" into an exact record.

Ids sent *by* clients are deliberately not honored — an outside caller
cannot choose its own trace id and pollute or collide the records.

Where known, responses also carry:

| Header | Meaning |
| --- | --- |
| `x-pilvia-release` | Which release served this response — useful mid-rollout and after a rollback. |
| `x-pilvia-isle` | Which isle served it. An isle is one named serving environment of the platform. |

A [background job](/data/jobs.md) run shares one trace id across all its
slices, so a whole sync reads as one story.

## Platform names are unlisted

Every response on a `pilvia.app` name carries:

```
x-robots-tag: noindex, nofollow
```

That covers a build URL or a branch alias (`<alias>--<app>.pilvia.app`, see
[Preview URLs](/hosting/previews.md)) and the app's own `<app>.pilvia.app`.
A site that is still being built stays out of search without a
`robots.txt`. A site on its own domain is not indexed a second time under
the platform name.

Two exceptions:

- **Custom domains never carry it.** What they say to crawlers is your
  site's business.
- **An app whose platform name is its public address declares it.** List
  the name in the manifest's `custom_domains`, and `<app>.pilvia.app`
  answers without the header:

  ```json
  {
    "name": "docs",
    "custom_domains": ["docs.pilvia.app"]
  }
  ```

  An app may declare its own platform name and no other. The declaration
  never lifts the header off a preview.

## Where the client is

Your server code receives two request headers stamped at the edge, from a
lookup of the client address the platform already holds:

| Header | Value |
| --- | --- |
| `x-pilvia-ip-country` | ISO 3166-1 alpha-2 country code, e.g. `FI`. |
| `x-pilvia-ip-city` | City name, **percent-encoded** — decode it with `decodeURIComponent` before comparing. |

Both are absent when the address is unknown to the database (private
ranges, uncovered ranges) — treat "absent" as "unknown", never as a default
country. Copies of these headers sent by clients are stripped before your
code runs, so a value you do see was set by the platform, not forged.

The lookup happens on the platform's own machines against a local
database; no third party sees the request. IP geolocation data by
[DB-IP](https://db-ip.com) (db-ip Lite), licensed
[CC BY 4.0](https://creativecommons.org/licenses/by/4.0/).

## Caching and content headers

Covered in detail in [Caching](/hosting/caching.md):

- `etag` — the asset's sha256; strong, always present on assets.
- `cache-control` — `public, max-age=0, must-revalidate`, or
  `public, max-age=31536000, immutable` on hash-named bundler output. On
  an app that requires sign-in, `public` reads `private`.
- `content-encoding` + `vary: accept-encoding` — negotiated compression.

On a page that has a [Markdown alternate](/hosting/static-sites.md#markdown-for-agents):

- `vary: accept-encoding, accept` — the answer is HTML or Markdown,
  depending on the request's `Accept`.
- `link` — `</guide.md>; rel="alternate"; type="text/markdown"` on the
  HTML, `</guide/>; rel="canonical"` on the Markdown.

## Redirects the platform owns

- `http://` → `https://`, path and query intact.
- Non-canonical custom domains → [`canonical_host`](/hosting/custom-domains.md),
  path and query intact, 301.
