Skip to content

Commit

Permalink
routing: add missing cache headers
Browse files Browse the repository at this point in the history
  • Loading branch information
hacdias committed Mar 7, 2024
1 parent 937754a commit a6cf746
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/routing/http-routing-v1.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,13 @@ This API uses a standard version prefix in the path, such as `/v1/...`. If a bac
- `404` (Not Found): must be returned if no matching records are found.
- `422` (Unprocessable Entity): request does not conform to schema or semantic constraints.

#### Response Headers

- `Content-Type`: the content type of this response, which MUST be `application/json` or `application/x-ndjson`.
- `Last-Modified`: the timestamp of the resolution.
- `Vary: Accept`: allows intermediate caches to play nicely with the different possible content types.
- `Cache-Control: public, max-age={TTL}`: cache TTL returned with the response. When present, it SHOULD be short for responses that do whose resolution ended in no results (e.g. 15 seconds), and CAN be longer for responses that have results (e.g. 5 minutes).

#### Response Body

```json
Expand Down Expand Up @@ -108,6 +115,13 @@ represented as a CIDv1 encoded with `libp2p-key` codec.
- `404` (Not Found): must be returned if no matching records are found.
- `422` (Unprocessable Entity): request does not conform to schema or semantic constraints.

#### Response Headers

- `Content-Type`: the content type of this response, which MUST be `application/json` or `application/x-ndjson`.
- `Last-Modified`: the timestamp of the resolution.
- `Vary: Accept`: allows intermediate caches to play nicely with the different possible content types.
- `Cache-Control: public, max-age={TTL}`: cache TTL returned with the response. When present, it SHOULD be short for responses that do whose resolution ended in no results (e.g. 15 seconds), and CAN be longer for responses that have results (e.g. 5 minutes).

#### Response Body

```json
Expand Down Expand Up @@ -148,7 +162,9 @@ Each object in the `Peers` list is a record conforming to the [Peer Schema](#pee
#### Response Headers

- `Etag`: a globally unique opaque string used for HTTP caching. MUST be derived from the protobuf record returned in the body.
- `Cache-Control: max-age={TTL}`: cache TTL returned with :ref[IPNS Record] that has `IpnsEntry.data[TTL] > 0`. When present, SHOULD match the TTL value from the record. When record was not found (HTTP 404) or has no TTL (value is `0`), implementation SHOULD default to `max-age=60`.
- `Cache-Control: public, max-age={TTL}`: cache TTL returned with :ref[IPNS Record] that has `IpnsEntry.data[TTL] > 0`. When present, SHOULD match the TTL value from the record. When record was not found (HTTP 404) or has no TTL (value is `0`), implementation SHOULD default to `max-age=60`. Implementations CAN also include other derivatives, such as `stale-while-revalidate` and `stale-if-error`.
- `Expires: {SIGNATURE_EXPIRATION}`: header with time when the signature expires.
- `Last-Modified`: with the timestamp of the resolution.

#### Response Body

Expand All @@ -170,6 +186,8 @@ The content body must be a [`application/vnd.ipfs.ipns-record`][application/vnd.
- `400` (Bad Request): the provided :ref[IPNS Record] or :ref[IPNS Name] are not valid.
- `406` (Not Acceptable): submitted content type is not supported. Error message returned in body should inform the user to retry with `Content-Type: application/vnd.ipfs.ipns-record`.

#### Response Headers

## Pagination

This API does not support pagination, but optional pagination can be added in a backwards-compatible spec update.
Expand Down

0 comments on commit a6cf746

Please sign in to comment.