Illustration of web push TTL, a notification waiting in a cloud server beside an hourglass while a laptop and phone are offline Illustration of web push TTL, a notification waiting in a cloud server beside an hourglass while a laptop and phone are offline

How Long Does a Web Push Notification Wait If the Device Is Offline?

Web push TTL decides how long a push service keeps a message for an offline device. Values to use, TTL 0, and the Urgency and Topic headers.

A web push notification waits only as long as its TTL (Time To Live) allows. TTL is a header in seconds that the sender sets on every message. If the device is offline, the push service stores the message until it reconnects or the TTL runs out. With TTL 0, it’s dropped unless the device is online right now.

Every time I debug “my notification arrived hours late” or “it never arrived”, the answer usually sits in one header. Web push has no inbox. A push service such as Firebase Cloud Messaging (FCM), Mozilla’s autopush or Apple’s web push service holds your message for a limited time, and you decide how long. Here’s how web push TTL works, which values make sense, and how the related Urgency and Topic headers change delivery.

Key facts at a glance:

  • TTL is required. The Web Push protocol in RFC 8030 says every push message request must include a TTL header, in seconds.
  • TTL 0 means “deliver now or not at all”.
  • The push service can shorten your TTL. It returns the value it actually applied in the TTL response header.
  • FCM keeps a message for up to four weeks (2,419,200 seconds), per the FCM message lifespan docs.
  • The popular web-push library for Node.js defaults to four weeks if you don’t set a TTL.

What is TTL in web push?

TTL (Time To Live) is the number of seconds a push service should keep a message if it can’t deliver it straight away. Your server sends it as an HTTP header with the encrypted payload, for example TTL: 3600 for one hour.

The flow is simple. Your server posts the message to the subscription’s endpoint URL. If the browser is connected, the push service delivers it within seconds. If the device is asleep, offline or the browser is fully closed, the push service queues the message. When the device reconnects before the TTL expires, the message is delivered and the service worker shows the notification. When the TTL expires first, the message is silently discarded.

So TTL is a promise about freshness, not a guarantee of delivery. It tells the push service when a message stops being worth showing.

What happens to a push notification when the device is offline?

When the device is offline, the push service stores the message and retries when the device comes back, as long as the TTL hasn’t run out. Nothing reaches the browser while it’s disconnected, so your service worker doesn’t run and no notification appears.

Here’s how the common cases play out:

Situation when you sendWhat happensNotification shown?
Device online, browser runningDelivered within secondsYes
Device online, browser closed (desktop)Queued until the browser starts againYes, if the TTL hasn’t expired
Device offline or switched offQueued until it reconnectsYes, if the TTL hasn’t expired
Any of the above with TTL 0Delivered only if the browser is reachable right nowOnly if delivered immediately
Subscription expired or revokedPush service rejects the request (404 or 410)No

On Android, Chrome can usually receive pushes even when the browser isn’t open in the foreground. On desktop, the browser process generally needs to be running. My post on whether web push works when the browser is closed covers that in detail.

What TTL should you use for different notifications?

Use a short TTL for anything time-sensitive and a longer one for evergreen content. The right number is simply “how long would this message still be useful?” Here are the values I start from:

Notification typeSuggested TTLWhy
Live sale ending at a fixed timeSeconds until the sale endsA late alert for an expired offer annoys people
Breaking news1 to 6 hours (3,600 to 21,600 s)Old breaking news isn’t breaking
One-time passcode or login alert60 to 300 secondsA stale code is useless and confusing
Webinar or event starting soonUntil the event startsAfter that, the link is pointless
New blog post or product1 to 3 days (86,400 to 259,200 s)Still relevant, but not forever
Evergreen content recirculationUp to 1 weekFine to arrive late

These are starting points, not rules. However, I’d avoid leaving every message on a library default of four weeks. A “flash sale, 2 hours left” notification that pops up three days later on a laptop that was in a drawer is worse than no notification at all.

What does TTL 0 do?

TTL 0 tells the push service to deliver the message immediately or drop it. Nothing is stored. It’s useful for messages that only make sense in real time, such as a live score update or an “agent is typing” style signal in a web app.

The trade-off is reach. Any subscriber whose device is offline or whose browser is closed at that exact moment simply never gets the message. So for marketing campaigns, TTL 0 usually loses more clicks than it saves. For one-time passcodes, a short TTL of a minute or two is usually a better balance; see my post on web push for OTP and 2FA.

Can the push service change your TTL?

Yes. RFC 8030 lets a push service reduce the TTL you ask for, and it reports the value it applied in the TTL header of its response. In practice, very long TTLs get capped. FCM, for example, documents a maximum lifespan of four weeks.

That means you shouldn’t rely on very long TTLs for anything important. If a message must reach someone weeks later, web push is the wrong channel. Email or an in-app message is a better fit.

How do the Urgency and Topic headers affect delivery?

Urgency and Topic are two optional headers that work alongside TTL. Urgency tells the push service how important a message is, so it can save battery on mobile devices. Topic lets a newer message replace an older one that’s still waiting in the queue.

Urgency

RFC 8030 section 5.3 defines four urgency values. The push service and device can use them to delay low-priority messages until the device is charging or on Wi-Fi:

Urgency valueIntended forExample
very-lowDelivery when the device is on power and Wi-FiWeekly digest
lowDelivery on either power or Wi-FiNew blog post
normal (default)Delivery when the device isn’t on low batteryMost campaigns
highDelivery even on low batteryIncoming call, security alert

Use “high” sparingly. If everything is urgent, nothing is.

Topic

A Topic header names the message, for example Topic: price-drop-123. If a message with the same topic is still queued for an offline device, the push service replaces it with the new one. As a result, the subscriber sees only the latest version when they reconnect. I explain how Topic differs from the notification tag option in my post on updating or recalling a web push notification.

How do you set TTL in code?

You set TTL as a header on the request to the push endpoint, or as an option in your web push library. For instance, with the Node.js web-push library:

const webpush = require('web-push');

await webpush.sendNotification(subscription, JSON.stringify({
  title: 'Flash sale ends at 6 pm',
  url: 'https://example.com/sale'
}), {
  TTL: 7200,          // keep for 2 hours if the device is offline
  urgency: 'normal',  // very-low | low | normal | high
  topic: 'flash-sale' // newer message with this topic replaces the queued one
});

The PHP library web-push-php and Python’s pywebpush expose the same TTL, urgency and topic options. If you call FCM’s HTTP v1 API directly, put them in the webpush.headers object of the message. For a full walkthrough, see my guides on sending web push with Node.js and PHP or Laravel. The web.dev guide to the Web Push protocol also explains each header.

Why do some notifications arrive late or not at all?

Most late or missing notifications come down to the device being offline, a long or short TTL, or low urgency on a phone saving battery. A delayed notification usually means it was queued and delivered when the device reconnected. A missing one usually means the TTL expired first, or the subscription itself is no longer valid.

Check these in order:

  1. Confirm the push service accepted the request (a 201 Created response).
  2. Check the TTL you sent and the TTL the service returned.
  3. Check whether the subscriber’s device was likely offline or the browser closed.
  4. Look for 404 or 410 responses, which mean the subscription has expired.
  5. Rule out device settings such as Focus modes, covered in my web push troubleshooting guide.

Where LaraPush fits

LaraPush is a self-hosted web push panel that you install on your own VPS, with a one-time licence from $499 (check LaraPush pricing). It sends through Firebase Cloud Messaging, so the FCM delivery rules above, including the four-week maximum lifespan, apply to it too. You get campaign scheduling, sent, delivered and clicked reports per campaign, and a REST API without call limits, listed on the features page. The trade-offs are no free plan and a server you maintain. For a wider comparison, see my guide to the best push notification services and tools.

Frequently asked questions

What is the default TTL for a web push notification?

The Web Push protocol has no default. RFC 8030 requires the sender to include a TTL header on every message. Libraries fill it in for you, though. The Node.js web-push library, for example, uses four weeks if you don’t set a value, so check your library’s default before relying on it.

What is the maximum TTL for web push?

It depends on the push service, because each service may reduce the TTL you request. Firebase Cloud Messaging documents a maximum message lifespan of four weeks, or 2,419,200 seconds. The push service returns the TTL it actually applied in its response header, so log that value if delivery timing matters.

Will a subscriber see an old notification when they come back online?

Yes, if the TTL hasn’t expired. The push service delivers queued messages when the device reconnects, and the service worker then shows them. That’s why time-sensitive campaigns need a short TTL. Otherwise an expired offer can appear hours or days later and confuse people.

Does TTL affect how long a notification stays on screen?

No. TTL only controls how long the push service keeps an undelivered message. Once the notification is shown, the browser and operating system decide how long it stays visible. To keep it on screen until clicked, you use the requireInteraction option where the browser supports it.

What TTL should I use for breaking news?

A few hours is a sensible range for breaking news, for example 3,600 to 21,600 seconds. After that, the story is usually old and a late alert can hurt trust. Use a longer TTL, such as one to three days, for evergreen articles and product announcements.

Leave a Reply

Your email address will not be published. Required fields are marked *