Set delivery controls from the last useful moment
Web Push TTL is the number of seconds a push service may retain an undelivered message. Urgency can influence when a device accepts it, while Topic can replace an older queued message. None of the three schedules a notification or proves that it reached a person.
- Start with
- The real-world time after which the message becomes stale or misleading.
- Then choose
- A TTL inside that window, the lowest honest urgency, and a Topic only when newer state should replace older state.
Write a usefulness deadline before a TTL
A sender normally knows the campaign creation time, planned send time, and business deadline. Convert that deadline into a remaining usefulness window when each attempt is made. The Web Push TTL should never extend beyond it. Queue delay, retries, and transit time consume the same window, so copying one large TTL across every campaign can surface expired prices, old scores, closed events, or reminders after the appointment.
RFC 8030 requires a non-negative TTL value in seconds on a Web Push request. A service can retain the message for less time than requested. A value of zero means the service can attempt immediate delivery when the user agent is available and then remove the message; it is not a high-priority flag.
Use a message-class ledger
| Message condition | Expiry rule | Urgency starting point | Replacement rule |
|---|---|---|---|
| A live event begins in 12 minutes | Expire before the start, less queue time already spent. | Normal or high only when the subscriber explicitly requested the time-sensitive alert. | Use one event-specific Topic if score or status updates supersede each other. |
| A saved item changed price | Expire when the displayed price is no longer verified, not at an arbitrary day boundary. | Low or normal. | Replace the prior queued price state for the same saved item. |
| A weekly reading digest is ready | Retain only until the next digest or editorial refresh. | Very-low or low. | Replace the previous undelivered digest rather than stacking several editions. |
| An account action needs review | Use a bounded window, but make the destination show current account state even after the notification expires. | Normal; reserve high for a genuinely urgent, requested event. | Replace only when the newer message fully supersedes the older one. |
The values above are operating examples, not platform guarantees. Test the push library and service you actually use, record the requested and returned TTL when available, and keep message text safe if it arrives near the end of its window.
Choose urgency without turning it into marketing priority
The protocol defines four urgency values: very-low, low, normal, and high. A missing value defaults to normal. Urgency exists partly so battery-powered devices can avoid waking for trivial messages. It does not make a promotional campaign important merely because a sender wants faster clicks.
- Use very-low for information that can wait for favorable device conditions.
- Use low for ordinary background updates whose value lasts.
- Use normal for requested reminders and conversational updates that should arrive in normal operation.
- Use high only for an event whose value is genuinely time-critical to that subscriber.
Urgency and the notification frequency policy solve different problems. Urgency describes delivery importance to the push system. A frequency rule decides whether the subscriber should receive the message at all.
Use Topic only for replaceable queued state
A Topic lets a new request replace one outstanding message with the same Topic for the same subscription. The RFC limits the value to a compact URL- and filename-safe token. The Topic is protocol metadata; it is not delivered to the service worker, and it is not a general audience label.
Good replacement cases
A current score, latest queue position, newest shipment estimate, or most recent unread-count state can replace an older undelivered version when only the newest state remains useful.
Unsafe replacement cases
Separate security events, distinct direct messages, and different requested reminders usually should not share a Topic. Replacing one would erase another queued event. When in doubt, ask whether the newer notification completely fulfills the older promise.
Coordinate retries with the same deadline
A transient service response can justify a bounded retry, but the retry worker must recalculate remaining usefulness first. If the deadline has passed, mark the attempt expired and stop. If time remains, cap the delay so the next request and its TTL still fit. The Web Push status-code runbook separates transient responses from permanent endpoint failures.
remaining = useful_until - now
if remaining <= 0:
mark_expired_without_send()
else:
ttl = min(policy_max_ttl, remaining)
send(ttl=ttl, urgency=class_urgency, topic=replace_key)
This pseudocode expresses a control boundary, not a copy-and-paste client. Use monotonic queue timing where appropriate, validate integer limits, and keep the authoritative destination state current.
Record enough evidence to explain a stale-message incident
The web push notification service can expose these controls and results, but the message owner must still define when the underlying information stops being useful.
- Store the message class, creation time, useful-until time, and policy version.
- Record queue entry, each attempt time, requested TTL, urgency, and redacted Topic.
- Preserve the push-service status and any returned retention information.
- Record whether the message was replaced, expired before send, accepted, or permanently rejected.
- Keep click and destination outcomes separate from provider acceptance.
These fields let an operator distinguish a wrong expiry policy from queue delay, retry delay, endpoint failure, or an out-of-date destination. They also keep the delivery metrics from counting an intentionally expired message as a mysterious failure.
Primary protocol source
RFC 8030, Generic Event Delivery Using HTTP Push, defines the TTL requirement, urgency values, Topic replacement behavior, service retention limits, and the distinction between push-service acceptance and later delivery.