Skip to main content

Optimize performance in your app built with XMTP

Follow these guidelines to optimize your app’s performance.

Use a local cache

If you're building a production-grade app, be sure to use an architecture that includes a local cache backed by an XMTP SDK.

Use the XMTP SDK to initially retrieve existing message data from the XMTP network and place it in the local cache. Asynchronously load new and updated message data as needed.

Build your app to get message data from the local cache.

For example, use the XMTP SDK to get conversation lists from the XMTP network. Store the conversation lists in the local cache. Build your app to get conversation lists from the local cache.

When building native iOS and Android mobile apps, you can use the device's encrypted container as the local cache to store decrypted data.

When building web apps, you can use the browser localStorage as the local cache to store encrypted data, decrypting data each time before display.

Cache the conversation list

Caching the conversation list can improve performance of client.conversations.list() by up to 90%.

Cache message histories

Serialize securely stored DecodedMessage histories, avoiding the need to download and decrypt the same message on every session.

Page through messages

Page through messages in a conversation instead of fetching them all at the same time.

Compress message content

Compress message content using a supported compression algorithm.

Check performance benchmarks

Consider how your app performs against these performance benchmarks:

  • Time to load conversation list: 8-15ms to decrypt invites per conversation
  • Sender UX: Time between sending a message and displaying the message in the conversation thread: ≤1 second
  • Recipient UX: Time between sending a message and displaying the message in the conversation thread: ≤1 second

Was the information on this page helpful?