TTL
A push message for an offline device needs a shelf life. The TTL request header tells a Web Push service how many seconds to retain a submitted message while the subscriber stays unreachable, after which the service drops the message undelivered.
Usage
An application server submitting a push message includes TTL on the POST to the subscription endpoint, and the specification requires the header on every submission. The push service stores the message up to the given lifetime and delivers on reconnection, answering with 201 Created either way.
The service echoes the retention it applied in a
TTL response header, and a service
capping long lifetimes returns the smaller number,
so reading the echo tells the sender what was
granted. A value of 0 requests immediate delivery
or nothing: the service forwards the message only
when the device is reachable now, fitting VoIP
rings and other signals with no value later.
The header pairs with Topic, which replaces a stored message instead of queueing a second one, and Urgency, which guides delivery timing on battery-constrained devices.
Values
A non-negative integer number of seconds. 0 means
deliver now or drop.
Example
A weather update worth an hour of retention. The service accepts the message and echoes the applied lifetime.
Request
POST /push/JzLQ3raZJfFBR0aqvOMsLrt54w4rJUsV HTTP/1.1
Host: push.example.re
TTL: 3600
Content-Length: 136
Response
HTTP/1.1 201 Created
TTL: 3600