Pushpad
Articles › Technical Insights, Web Push Notifications

Web Push Notifications: what happens if the client is offline?

  • # deliverability
  • # push-api

If you are a beginner with web push notifications, you may wonder what happens to the notifications sent when the client is offline or the device is turned off. What is the behavior of the notifications in this case? Do they get delivered or are they lost?

We first need to clarify the technology used to send the notifications. There are many different technologies that allow to send a notification in real time to a client that is currently on your website. For example: polling, long polling, WebSocket, Server-Sent Events and more.

However there is only one technology that currently allows you to reach a client that is not on your website: web push notifications can be delivered at any time, even when a user is not surfing your website. "Web Push Notifications" is a general term to indicate a combination of technologies: Push API, Web Push and Web Notifications.

For example, if a user is subscribed to the notifications of Website1, but is now surfing Website2 and Website3, he can still receive the notifications from Website1 in real time.

These are the rules for web push notifications:

  • The user is on your website: the notifications are delivered instantly.
  • The user is surfing other websites (the browser is open): the notifications are delivered instantly.
  • The user has an active internet connection, but the browser is closed: depending on the OS / browser the notifications are delivered instantly or they will be delivered later when the user opens the browser. In particular, on mobile you can usually receive the notifications instantly even when the browser is closed, while on desktop you may need to open the browser.
  • The user is not reachable (e.g. device turned off or no internet connection): in this case the notifications cannot be delivered immediately and they will be delivered later when the user becomes online.

It is now clear that web push notifications are not lost if the user is offline: the notifications are simply delivered later. Your application doesn't need to worry about that: you can simply send the notifications to the push service, which will then become responsible for delivering the notifications as soon as possible.

There is however an important factor to consider: for how long the push service will try to deliver a notification (before discarding it)? This is determined by the TTL (Time To Live) of the notification, which is a parameter that you should set carefully when you send a notification. Usually you can ask the push service to keep the notification and try to deliver it for a maximum of 28 days: after that amount of time the notification will be discarded by the push service. If you want, you can also voluntarily reduce the TTL in order to discard the notification earlier.

Finally, if you are looking for a reliable service to send web push notifications from your website, you can try Pushpad. Since Pushpad is built using the Push API / Web Push, your notifications will be always delivered, even when the user has closed your website.