Articles › Sending Notifications, Web Push Notifications

Web Push TTL: definition and maximum value

  • # deliverability
  • # push-api

When you send a web push notification, you need to set the TTL: what is it? What value should you use? This article describes the TTL and the best practices for setting its value.

TTL means "Time To Live" and represents the lifespan of a web push message.

The application server sends a notification to a push service, which then delivers the notification to the user browser as soon as the user becomes available.

The user is usually reachable when he turns on the smartphone and has an internet connection. On desktop, the user may also need to launch the browser application in order to receive the notifications.

What happens if you send a notification and the user is not reachable (e.g. his smartphone is turned off)? In this case the push service keeps the notification and will deliver it later, when the user becomes available.

The TTL defines for how long the push service will attempt to deliver the notification to the browser. If the push service cannot reach the user within the TTL, the notification will be discarded.

The TTL value is expressed in seconds.

The minimum value is 0, which means that the notification will be delivered only if the device is reachable immediately. It can be useful for example to notify a phone call or similar. For normal notifications it is not recommended to use low values, because most notifications will be discarded and will never reach the user.

The maximum value is not clearly set by the Web Push standard: it allows 2^31 seconds (68 years), but it is also says that a push service can decide to limit this value. In practice all push services greatly limit this value: the maximum value supported by all major push services is 2419200 seconds (4 weeks). In any case if you set a value greater than the limit, it shouldn't be a problem: the standard says that the browser push services (e.g. Mozilla autopush, FCM, etc.) should decrease the TTL automatically if it's too large.

You should always use a balanced value for the TTL:

  • if you set a TTL that is too small, then a user may not receive the notification (negative impact on deliverability)
  • if you set a TTL that is too large, then a user, when he becomes available, may receive too many messages that are no longer relevant (e.g. something confusing or that is no longer true)

If you use Pushpad for sending the notifications from your website, you can also read the documentation about TTL.

Finally if you want more information about the TTL, you can read the official definition of TTL given by the Web Push standard (RFC 8030).