Skip to content

Commit fbb66bd

Browse files
lidel2color
andauthored
docs: ipns ttl tips (#2002)
Co-authored-by: Daniel Norman <[email protected]>
1 parent 5b69bdf commit fbb66bd

File tree

1 file changed

+23
-3
lines changed

1 file changed

+23
-3
lines changed

docs/concepts/ipns.md

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ description: Learn about mutability in IPFS, InterPlanetary Name System (IPNS),
1818
- [Publishing IPNS records over PubSub lifecycle](#publishing-ipns-records-over-pubsub-lifecycle)
1919
- [Tradeoffs between consistency vs. availability](#tradeoffs-between-consistency-vs-availability)
2020
- [IPNS record validity](#ipns-record-validity)
21+
- [IPNS record TTL](#ipns-record-ttl)
2122
- [Practical considerations](#practical-considerations)
2223
- [IPNS in practice](#ipns-in-practice)
2324
- [Resolving IPNS names using IPFS gateways](#resolving-ipns-names-using-ipfs-gateways)
@@ -177,13 +178,32 @@ Availability means resolving to a valid IPNS record, at the cost of potentially
177178

178179
When setting the `validity` (referred to as [`lifetime` by Kubo](https://github.com/ipfs/kubo/blob/master/docs/config.md#ipnsrecordlifetime)) field of an IPNS record, you typically need to choose whether you favor **consistency** (short validity period, e.g. 48 hours) or **availability** (long validity period, e.g. 1 month), due to the inherent trade-off between the two.
179180

181+
#### IPNS record TTL
182+
183+
If you experience slow IPNS update propagation, the Time-to-Live (TTL) setting is the first thing to check.
184+
185+
##### TTL as a Publisher
186+
187+
When you publish an IPNS Record, the default TTL, which controls caching, might be set to a high value, such as one hour. If you want third-party gateways and nodes to bypass the cache and check for updates more frequently, consider lowering this value.
188+
189+
- **Kubo**: Refer to the `--ttl` option in [`ipfs name publish --help`](https://docs.ipfs.tech/reference/kubo/cli/#ipfs-name-publish) for details on adjusting this setting.
190+
- **Note**: If your IPNS Record is used behind a DNSLink (e.g., `/ipns/example.com` pointing to `/ipns/k51..libp2p-key`), the DNS TXT record at `_dnslink.example.com` has its own TTL. This DNS TTL also affects caching. Ensure that both TTL values are aligned for consistent behavior.
191+
192+
##### TTL as a Gateway Operator
193+
194+
You should have the ability to override the TTL provided by the publisher and set a lower cap on how long resolution results are cached.
195+
196+
- **Kubo**: Configure this using the [`Ipns.MaxCacheTTL`](https://github.com/ipfs/kubo/blob/master/docs/config.md#ipnsmaxcachettl) setting.
197+
- **Rainbow**: Adjust this with the [`RAINBOW_IPNS_MAX_CACHE_TTL`](https://github.com/ipfs/rainbow/blob/main/docs/environment-variables.md#rainbow_ipns_max_cache_ttl) environment variable.
198+
180199
#### Practical considerations
181200

182-
One of the most important things to consider with IPNS names is **how frequently you intend on updating the name**.
201+
The most important thing to consider with IPNS names is **how frequently you intend on updating the name** and **how long a valid record should be cached before checking for an update**.
183202

184-
Practically, two levers within your control determine where your IPNS name is on the spectrum between consistency and availability:
203+
Practically, levers within your control determine where your IPNS name is on the spectrum between consistency and availability:
185204

186-
- **IPNS record validity:** longer validity will veer towards availability. Moreover, longer validity will reduce the dependence on the key holder (which for most purposes is stored on a single machine and rare shared) since the record can continue to persist without requiring the private key holder to sign a new record. Another benefit of a longer validity is that the transport can be delegated to other nodes or services (such as [w3name](https://staging.web3.storage/docs/how-tos/w3name/)), without compromising the private key.
205+
- **IPNS record validity:** longer validity will veer towards availability. Moreover, longer validity will reduce the dependence on the key holder (which for most purposes is stored on a single machine and rare shared) since the record can continue to persist without requiring the private key holder to sign a new record. Another benefit of a longer validity is that the transport can be delegated to other nodes or services (such as [w3name](https://docs.storacha.network/how-to/w3name/)), without compromising the private key.
206+
- **IPNS record TTL:** longer TTL trades update propagation speed for better page load performance and resiliency.
187207
- **Transport mechanism:** the DHT veers towards consistency while PubSub veers towards availability. However, with Kubo, IPNS names are always published to the DHT, while PubSub is opt-in. For most purposes, enabling PubSub is a net gain unless you hit the upper limit of connections as a result of too many PubSub subscriptions.
188208

189209
## IPNS in practice

0 commit comments

Comments
 (0)