# Best practices for IPFS builders

Some IPFS features are not enabled or set as defaults, but we encourage you to use them under the right circumstances.

# Use CIDv1 for future-proof addressing and case-insenstive contexts

There are two versions of CIDs (Content Identifiers), CIDv0 and CIDv1.

CIDv0 is simpler but much less flexible than CIDv1. It doesn't offer the future-proof and case-insensitive addressing that CIDv1 offers. You can quickly tell the difference between v0 and v1 CIDs, because v0 CIDs always start with Qm. Many of the existing IPFS tools still generate CIDs in v0, for example:

Some features use CIDv1 by default:

Use CIDv1 when you want:

  • future-proof addressing: CIDv1 provides leading identifiers, such as multicodec (opens new window), which indicate the format of the target content so that the CID can support future CID formats.
  • case-insensitive addressing for more flexibility

To opt in, use the --cid-version flag in the CLI:

ipfs add --cid-version 1

To convert a CID from v0 to v1, see CID conversion (opens new window).

For more information on content addressing and CID versions, see Content Addressing and CIDs.

# Enable pubsub for fast IPNS

As a standalone feature, pubsub is a way to publish and subscribe to messages. However, within ipns, you can use it to accelerate publishing and resolution of IPNS records. Pubsub is an experimental feature, so use it with care. It's disabled by default.

To use this feature, use Ipns.UsePubsub before starting the IPFS daemon:

ipfs config --json Ipns.UsePubsub true
ipfs daemon

From this point on, IPNS will be resolved using both the pubsub and the DHT. Learn more about the limitations of this experimental feature here:

# Enable Garbage Collection if your data churn is expected to be high

Storage is finite, so nodes need to clear out some of their previously cached resources to make room for new resources. This process is called garbage collection.

If you expect your data churn to be high, you may want to enable garbage collection to reclaim memory occupied by objects that are no longer in use.

However, you may also have data that you value. To make sure that you keep data that is valuable to you, pin the valued data. The following pages are useful for learning how pinning works:

Then you can safely enable garbage collection for all other data. See:

To prevent one website from improperly accessing HTTP session data associated with a different website, use a:

  • subdomain gateway, or
  • DNSLink