By default, all messages sent on Ably will be stored for 2 minutes on our servers. This allows for clients who disconnect for less than 2 minutes to recover any messages they might have missed, through our History API. The recovering client will receive these messages in the original order they were sent, and this is applicable to both regular channel messages and presence messages.
However, if your use case requires longer retention of messages, i.e. longer than the default two minutes, you can enable “persisted history”: using both the Realtime and the REST libraries of Ably. If persisted history is enabled for a channel, its messages will typically be stored for 24 – 72 hours on disk.
Enabling persistent history
Every message that is persisted to or retrieved from disk counts as an extra message towards your monthly quota. For example, for a channel that has persistence enabled, if a message is published, two messages will be deducted from your monthly quota. If the message is later retrieved from history, another message will be deducted from your monthly quota.
To enable history on a channel, it is necessary to add a channel rule in the settings of your application dashboard. See the documentation on channel rules for further information on what they are and how to configure them.