You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/routing/http-routing-v1.md
+29-2Lines changed: 29 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@ description: >
4
4
Delegated routing is a mechanism for IPFS implementations to use for offloading
5
5
content routing, peer routing and naming to another process/server. This specification describes
6
6
an HTTP API for delegated routing of content, peers, and IPNS.
7
-
date: 2023-08-31
7
+
date: 2024-03-22
8
8
maturity: reliable
9
9
editors:
10
10
- name: Gus Eggert
@@ -71,6 +71,17 @@ This API uses a standard version prefix in the path, such as `/v1/...`. If a bac
71
71
-`404` (Not Found): must be returned if no matching records are found.
72
72
-`422` (Unprocessable Entity): request does not conform to schema or semantic constraints.
73
73
74
+
#### Response Headers
75
+
76
+
-`Content-Type`: the content type of this response, which MUST be `application/json` or `application/x-ndjson` (see [streaming](#streaming)).
77
+
-`Last-Modified`: an HTTP-date timestamp ([RFC9110, Section 5.6.7](https://www.rfc-editor.org/rfc/rfc9110#section-5.6.7)) of the resolution, allowing HTTP proxies and CDNs to support inexpensive update checks via `If-Modified-Since`
78
+
-`Cache-Control: public, max-age={ttl}, public, stale-while-revalidate={max-ttl}, stale-if-error={max-ttl}`: meaningful cache TTL returned with the response.
79
+
- The `max-age` SHOULD be shorter for responses whose resolution ended in no results (e.g. 15 seconds),
80
+
and longer for responses that have results (e.g. 5 minutes).
81
+
- Implementations SHOULD include `max-ttl`, set to the maximum cache window of the underlying routing system.
82
+
For example, if Amino DHT results are returned, `stale-while-revalidate` SHOULD be set to `172800` (48h, which at the time of writing this specification, is the provider record expiration window).
83
+
-`Vary: Accept`: allows intermediate caches to play nicely with the different possible content types.
84
+
74
85
#### Response Body
75
86
76
87
```json
@@ -108,6 +119,17 @@ represented as a CIDv1 encoded with `libp2p-key` codec.
108
119
-`404` (Not Found): must be returned if no matching records are found.
109
120
-`422` (Unprocessable Entity): request does not conform to schema or semantic constraints.
110
121
122
+
#### Response Headers
123
+
124
+
-`Content-Type`: the content type of this response, which MUST be `application/json` or `application/x-ndjson` (see [streaming](#streaming)).
125
+
-`Last-Modified`: an HTTP-date timestamp ([RFC9110, Section 5.6.7](https://www.rfc-editor.org/rfc/rfc9110#section-5.6.7)) of the resolution, allowing HTTP proxies and CDNs to support inexpensive update checks via `If-Modified-Since`
126
+
-`Cache-Control: public, max-age={ttl}, public, stale-while-revalidate={max-ttl}, stale-if-error={max-ttl}`: meaningful cache TTL returned with the response.
127
+
- When present, `ttl` SHOULD be shorter for responses whose resolution ended in no results (e.g. 15 seconds),
128
+
and longer for responses that have results (e.g. 5 minutes).
129
+
- Implementations SHOULD include `max-ttl`, set to the maximum cache window of the underlying routing system.
130
+
For example, if Amino DHT results are returned, `stale-while-revalidate` SHOULD be set to `172800` (48h, which at the time of writing this specification, is the provider record expiration window).
131
+
-`Vary: Accept`: allows intermediate caches to play nicely with the different possible content types.
132
+
111
133
#### Response Body
112
134
113
135
```json
@@ -148,7 +170,12 @@ Each object in the `Peers` list is a record conforming to the [Peer Schema](#pee
148
170
#### Response Headers
149
171
150
172
-`Etag`: a globally unique opaque string used for HTTP caching. MUST be derived from the protobuf record returned in the body.
151
-
-`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`.
173
+
-`Cache-Control: public, max-age={ttl}, public, stale-while-revalidate={sig-ttl}, stale-if-error={sig-ttl}`: meaningful cache TTL returned with :ref[IPNS Record]
174
+
- The `max-age` value in seconds SHOULD match duration from `IpnsEntry.data[TTL]`, if present and bigger than `0`. Otherwise, implementation SHOULD default to `max-age=60`.
175
+
- Implementations SHOULD include `sig-ttl`, set to the remaining number of seconds the returned IPNS Record is valid.
176
+
-`Expires:`: an HTTP-date timestamp ([RFC9110, Section 5.6.7](https://www.rfc-editor.org/rfc/rfc9110#section-5.6.7)) when the validity of IPNS Record expires (if `ValidityType=0`, when signature expires)
177
+
-`Last-Modified`: an HTTP-date timestamp of when cacheable resolution occured: allows HTTP proxies and CDNs to support inexpensive update checks via `If-Modified-Since`
178
+
-`Vary: Accept`: allows intermediate caches to play nicely with the different possible content types.
0 commit comments