An outbox stores message 42 and register(‘send-outbox’) fulfils while the page is open. The device goes offline before the sync event. Hours later the event fires, but the first fetch rejects and the user agent schedules a retry. The message becomes delivered only after a later event receives and verifies the server acknowledgement. Four stages share one tag but require four evidence rows.
This lesson continues The Gold Standard of Websites, the Gold Standard of Education and the How X Works hub. Every outbox, tag, retry and server response is an original teaching fixture. The lesson does not promise execution at a chosen time, universal browser support, exactly-once delivery, unrestricted background work or success merely because a device reports online.
Record outbox item ID, durable-write result, service worker registration and active state, sync tag, register settlement, getTags result, event time, lastChance, waitUntil promise, request ID, server response and commit evidence, retry count, browser and power or network conditions.
The WICG Web Background Synchronization Draft Community Group Report defines registrations, tags, event states, retries and lastChance. The W3C Service Workers Editor’s Draft defines service worker registration, lifetime and extendable events. The lesson states limited implementation support and treats scheduling heuristics as user-agent decisions.
THE GOLD STANDARD · WEBSITES
A registered tag is an opportunity request, not a delivery receipt
registration.sync.register(tag) records or updates a one-off background sync registration when the preconditions pass. Later, the user agent may fire a sync event in the service worker. Successful application work depends on the promise passed to event.waitUntil(), the network and the server response. Registration fulfilment alone does not prove that the event fired, that the request succeeded or that the server committed the data.
Fast route
Start with the decisive rule.
Start this route
Measurement route
Build the browser state and evidence ledger.
Start this route
Comparison route
Separate the nearest lookalikes.
Start this route
Transfer route
Change the context and retest.
Start this route
Reporting route
State limits and continue reading.
Start this route
Chapter contents
Open the full chapter index
- 1. Give the four-stage rule
- 2. Write the outbox first
- 3. Understand register fulfilment
- 4. Use tags as coordination keys
- 5. Require an active service worker
- 6. Trace online as a weak premise
- 7. Use waitUntil for the real work
- 8. Validate server acknowledgement
- 9. Design idempotent retries
- 10. Interpret lastChance narrowly
- 11. Keep re-registration during firing visible
- 12. Do not promise a schedule
- 13. Handle unsupported browsers
- 14. Protect privacy and resources
- 15. Repair common shortcuts
- 16. Answer practical questions
- 17. Build a reproducible sync ledger
- 18. Use the drafts and continue
1. Give the four-stage rule
Separate durable outbox write, sync registration, sync event execution and server-confirmed completion. Each stage can succeed while the next remains pending or fails.
Original worked example. Message 42 is stored, the tag registers, the first event fetch fails, and the second event receives acknowledgement 884. The objects, values and observations are explicit so the reader can reconstruct the decision instead of trusting a label.
Changed-context transfer. Keep registration fixed but make the server return a retryable failure. State what changed, predict the consequence and revise only the conclusion that depended on that condition.
Practical evidence check. Log one timestamp and settlement field for every stage. If this check fails, mark the claim unavailable and repair the method before continuing.
Keep configuration, browser state and the final claim in separate fields so a convenient interface label cannot rewrite platform evidence.
Before closing, reconcile the original fixture against the chapter rule: identify the relevant objects, state, event order and missing evidence; change one condition and mark the first unsupported inference. Preserve the raw trace beside the revised result. End the chapter with three sentences: what the evidence establishes, what it does not establish and what observation would change the conclusion. This keeps the lesson useful when the browser, context or platform state changes. A strong record also names the datum, denominator, section or coordinate system that governed the decision, so a later reader can repeat the reasoning without importing an unstated shortcut.
2. Write the outbox first
Background scheduling cannot recover data that was never durably stored. Register only after the application can identify the work later.
Original worked example. The compose page commits message 42 to IndexedDB before calling register(‘send-outbox’). The objects, values and observations are explicit so the reader can reconstruct the decision instead of trusting a label.
Changed-context transfer. Reverse the order and close the page after registration to expose the missing payload risk. State what changed, predict the consequence and revise only the conclusion that depended on that condition.
Practical evidence check. Verify the database transaction and item ID before the registration call. If this check fails, mark the claim unavailable and repair the method before continuing.
Use a positive case, a clean negative case and an unavailable case. Unavailable evidence means the required field could not be established.
Before closing, reconcile the original fixture against the chapter rule: identify the relevant objects, state, event order and missing evidence; change one condition and mark the first unsupported inference. Preserve the raw trace beside the revised result. End the chapter with three sentences: what the evidence establishes, what it does not establish and what observation would change the conclusion. This keeps the lesson useful when the browser, context or platform state changes. A strong record also names the datum, denominator, section or coordinate system that governed the decision, so a later reader can repeat the reasoning without importing an unstated shortcut.
Previous chapter · Contents · Next chapter
3. Understand register fulfilment
A fulfilled register() promise means the registration algorithm accepted or updated the tag. It is not the sync event’s result.
Original worked example. register() resolves at t1; no service worker sync log appears until t8 after connectivity returns. The objects, values and observations are explicit so the reader can reconstruct the decision instead of trusting a label.
Changed-context transfer. Keep the tag but remain online and observe a potentially earlier firing without promising immediacy. State what changed, predict the consequence and revise only the conclusion that depended on that condition.
Practical evidence check. Record register settlement and event dispatch as separate events. If this check fails, mark the claim unavailable and repair the method before continuing.
Change one consequential premise while keeping the rest fixed. Predict the new branch before inspecting it and preserve disagreement.
Before closing, reconcile the original fixture against the chapter rule: identify the relevant objects, state, event order and missing evidence; change one condition and mark the first unsupported inference. Preserve the raw trace beside the revised result. End the chapter with three sentences: what the evidence establishes, what it does not establish and what observation would change the conclusion. This keeps the lesson useful when the browser, context or platform state changes. A strong record also names the datum, denominator, section or coordinate system that governed the decision, so a later reader can repeat the reasoning without importing an unstated shortcut.
Previous chapter · Contents · Next chapter
4. Use tags as coordination keys
A tag identifies a sync registration for a service worker registration. Re-registering the same tag updates state rather than creating an unlimited queue of identical jobs.
Original worked example. Three messages share send-outbox; one registration prompts the worker to drain the durable queue. The objects, values and observations are explicit so the reader can reconstruct the decision instead of trusting a label.
Changed-context transfer. Use one tag per message and compare registration volume and recovery semantics. State what changed, predict the consequence and revise only the conclusion that depended on that condition.
Practical evidence check. Save tags, getTags results and the mapping to outbox work. If this check fails, mark the claim unavailable and repair the method before continuing.
Carry one plausible alternative through the state ledger, then choose the next observation that separates it from the leading account.
Before closing, reconcile the original fixture against the chapter rule: identify the relevant objects, state, event order and missing evidence; change one condition and mark the first unsupported inference. Preserve the raw trace beside the revised result. End the chapter with three sentences: what the evidence establishes, what it does not establish and what observation would change the conclusion. This keeps the lesson useful when the browser, context or platform state changes. A strong record also names the datum, denominator, section or coordinate system that governed the decision, so a later reader can repeat the reasoning without importing an unstated shortcut.
Previous chapter · Contents · Next chapter
5. Require an active service worker
Sync registration belongs to a ServiceWorkerRegistration and needs its worker state. A page script alone cannot receive the background event.
Original worked example. navigator.serviceWorker.ready supplies a registration with an active worker before sync.register(). The objects, values and observations are explicit so the reader can reconstruct the decision instead of trusting a label.
Changed-context transfer. Attempt the call while the registration lacks an active worker and preserve InvalidStateError. State what changed, predict the consequence and revise only the conclusion that depended on that condition.
Practical evidence check. Log installing, waiting and active identities with the chosen registration. If this check fails, mark the claim unavailable and repair the method before continuing.
Name the handle, registration, event, manifest or browsing context involved. Similar visible results can come from different platform paths.
Before closing, reconcile the original fixture against the chapter rule: identify the relevant objects, state, event order and missing evidence; change one condition and mark the first unsupported inference. Preserve the raw trace beside the revised result. End the chapter with three sentences: what the evidence establishes, what it does not establish and what observation would change the conclusion. This keeps the lesson useful when the browser, context or platform state changes. A strong record also names the datum, denominator, section or coordinate system that governed the decision, so a later reader can repeat the reasoning without importing an unstated shortcut.
Previous chapter · Contents · Next chapter
6. Trace online as a weak premise
User-agent online status can trigger an opportunity, but it does not prove the destination is reachable or the request will succeed.
Original worked example. The network interface is online while the API host times out; the sync event still rejects its work promise. The objects, values and observations are explicit so the reader can reconstruct the decision instead of trusting a label.
Changed-context transfer. Point to a reachable host that returns 503 and compare transport with application failure. State what changed, predict the consequence and revise only the conclusion that depended on that condition.
Practical evidence check. Record connectivity observation, fetch settlement, HTTP status and server body separately. If this check fails, mark the claim unavailable and repair the method before continuing.
Archive source, fixture, options, events, timestamps, browser version and raw exceptions so another reader can reproduce the conclusion.
Before closing, reconcile the original fixture against the chapter rule: identify the relevant objects, state, event order and missing evidence; change one condition and mark the first unsupported inference. Preserve the raw trace beside the revised result. End the chapter with three sentences: what the evidence establishes, what it does not establish and what observation would change the conclusion. This keeps the lesson useful when the browser, context or platform state changes. A strong record also names the datum, denominator, section or coordinate system that governed the decision, so a later reader can repeat the reasoning without importing an unstated shortcut.
Previous chapter · Contents · Next chapter
7. Use waitUntil for the real work
event.waitUntil(promise) extends the event lifetime and makes that promise’s outcome part of sync success. Fire-and-forget work can be terminated early.
Original worked example. The worker passes the outbox drain promise to waitUntil and deletes items only after acknowledgement. The objects, values and observations are explicit so the reader can reconstruct the decision instead of trusting a label.
Changed-context transfer. Remove waitUntil and simulate worker termination before the request completes. State what changed, predict the consequence and revise only the conclusion that depended on that condition.
Practical evidence check. Verify the promise chain includes fetch, response validation and local commit. If this check fails, mark the claim unavailable and repair the method before continuing.
Keep configuration, browser state and the final claim in separate fields so a convenient interface label cannot rewrite platform evidence.
Before closing, reconcile the original fixture against the chapter rule: identify the relevant objects, state, event order and missing evidence; change one condition and mark the first unsupported inference. Preserve the raw trace beside the revised result. End the chapter with three sentences: what the evidence establishes, what it does not establish and what observation would change the conclusion. This keeps the lesson useful when the browser, context or platform state changes. A strong record also names the datum, denominator, section or coordinate system that governed the decision, so a later reader can repeat the reasoning without importing an unstated shortcut.
Previous chapter · Contents · Next chapter
8. Validate server acknowledgement
A fulfilled fetch promise or HTTP response is not automatically a committed application action. Define the acknowledgement needed for idempotent completion.
Original worked example. POST /messages returns 200 with messageId 42 and commitId 884; only then is the outbox row marked sent. The objects, values and observations are explicit so the reader can reconstruct the decision instead of trusting a label.
Changed-context transfer. Return an HTML login page with status 200 and ensure schema validation blocks deletion. State what changed, predict the consequence and revise only the conclusion that depended on that condition.
Practical evidence check. Store request ID, status, content type, parsed acknowledgement and commit evidence. If this check fails, mark the claim unavailable and repair the method before continuing.
Use a positive case, a clean negative case and an unavailable case. Unavailable evidence means the required field could not be established.
Before closing, reconcile the original fixture against the chapter rule: identify the relevant objects, state, event order and missing evidence; change one condition and mark the first unsupported inference. Preserve the raw trace beside the revised result. End the chapter with three sentences: what the evidence establishes, what it does not establish and what observation would change the conclusion. This keeps the lesson useful when the browser, context or platform state changes. A strong record also names the datum, denominator, section or coordinate system that governed the decision, so a later reader can repeat the reasoning without importing an unstated shortcut.
Previous chapter · Contents · Next chapter
9. Design idempotent retries
A rejected event can be retried under user-agent heuristics. Repeated requests must not create duplicate messages or charges.
Original worked example. Both attempts carry operation key msg-42; the server returns the same commit record for the duplicate. The objects, values and observations are explicit so the reader can reconstruct the decision instead of trusting a label.
Changed-context transfer. Lose the first response after the server commits and rerun the event. State what changed, predict the consequence and revise only the conclusion that depended on that condition.
Practical evidence check. Verify server deduplication and local reconciliation rather than counting requests. If this check fails, mark the claim unavailable and repair the method before continuing.
Change one consequential premise while keeping the rest fixed. Predict the new branch before inspecting it and preserve disagreement.
Before closing, reconcile the original fixture against the chapter rule: identify the relevant objects, state, event order and missing evidence; change one condition and mark the first unsupported inference. Preserve the raw trace beside the revised result. End the chapter with three sentences: what the evidence establishes, what it does not establish and what observation would change the conclusion. This keeps the lesson useful when the browser, context or platform state changes. A strong record also names the datum, denominator, section or coordinate system that governed the decision, so a later reader can repeat the reasoning without importing an unstated shortcut.
Previous chapter · Contents · Next chapter
10. Interpret lastChance narrowly
lastChance indicates the user agent does not plan further attempts after the current one. It does not guarantee success or define one universal retry count.
Original worked example. The final event sees lastChance true, still fails, preserves the outbox and notifies the user that manual retry is needed. The objects, values and observations are explicit so the reader can reconstruct the decision instead of trusting a label.
Changed-context transfer. Make the final attempt succeed and confirm the same flag does not taint the result. State what changed, predict the consequence and revise only the conclusion that depended on that condition.
Practical evidence check. Log the flag, work outcome and remaining outbox state. If this check fails, mark the claim unavailable and repair the method before continuing.
Carry one plausible alternative through the state ledger, then choose the next observation that separates it from the leading account.
Before closing, reconcile the original fixture against the chapter rule: identify the relevant objects, state, event order and missing evidence; change one condition and mark the first unsupported inference. Preserve the raw trace beside the revised result. End the chapter with three sentences: what the evidence establishes, what it does not establish and what observation would change the conclusion. This keeps the lesson useful when the browser, context or platform state changes. A strong record also names the datum, denominator, section or coordinate system that governed the decision, so a later reader can repeat the reasoning without importing an unstated shortcut.
Previous chapter · Contents · Next chapter
11. Keep re-registration during firing visible
Registering the same tag while its event is firing can move the internal state so another opportunity remains after current work.
Original worked example. A new message arrives during an outbox drain and re-registers send-outbox; the next pass handles the new row. The objects, values and observations are explicit so the reader can reconstruct the decision instead of trusting a label.
Changed-context transfer. Add the item before the worker snapshots the queue and compare whether one or two passes are needed. State what changed, predict the consequence and revise only the conclusion that depended on that condition.
Practical evidence check. Record queue snapshot, registration time and event sequence. If this check fails, mark the claim unavailable and repair the method before continuing.
Name the handle, registration, event, manifest or browsing context involved. Similar visible results can come from different platform paths.
Before closing, reconcile the original fixture against the chapter rule: identify the relevant objects, state, event order and missing evidence; change one condition and mark the first unsupported inference. Preserve the raw trace beside the revised result. End the chapter with three sentences: what the evidence establishes, what it does not establish and what observation would change the conclusion. This keeps the lesson useful when the browser, context or platform state changes. A strong record also names the datum, denominator, section or coordinate system that governed the decision, so a later reader can repeat the reasoning without importing an unstated shortcut.
Previous chapter · Contents · Next chapter
12. Do not promise a schedule
User agents choose firing and retry times under connectivity, power, privacy and resource heuristics. The API is not a precise alarm clock.
Original worked example. The same fixture fires after 20 seconds on one run and after reopening the browser on another. The objects, values and observations are explicit so the reader can reconstruct the decision instead of trusting a label.
Changed-context transfer. Enable battery saver and retain the changed delay as implementation evidence. State what changed, predict the consequence and revise only the conclusion that depended on that condition.
Practical evidence check. Publish ranges and conditions, not a guaranteed deadline. If this check fails, mark the claim unavailable and repair the method before continuing.
Archive source, fixture, options, events, timestamps, browser version and raw exceptions so another reader can reproduce the conclusion.
Before closing, reconcile the original fixture against the chapter rule: identify the relevant objects, state, event order and missing evidence; change one condition and mark the first unsupported inference. Preserve the raw trace beside the revised result. End the chapter with three sentences: what the evidence establishes, what it does not establish and what observation would change the conclusion. This keeps the lesson useful when the browser, context or platform state changes. A strong record also names the datum, denominator, section or coordinate system that governed the decision, so a later reader can repeat the reasoning without importing an unstated shortcut.
Previous chapter · Contents · Next chapter
13. Handle unsupported browsers
Limited implementation support requires an in-page retry or explicit Send again path. The outbox remains the source of truth.
Original worked example. When SyncManager is absent, the app drains the outbox while open and leaves pending items visible. The objects, values and observations are explicit so the reader can reconstruct the decision instead of trusting a label.
Changed-context transfer. Close the page mid-request and verify the next launch reconciles the item. State what changed, predict the consequence and revise only the conclusion that depended on that condition.
Practical evidence check. Feature-detect, preserve data and label pending versus sent accessibly. If this check fails, mark the claim unavailable and repair the method before continuing.
Keep configuration, browser state and the final claim in separate fields so a convenient interface label cannot rewrite platform evidence.
Before closing, reconcile the original fixture against the chapter rule: identify the relevant objects, state, event order and missing evidence; change one condition and mark the first unsupported inference. Preserve the raw trace beside the revised result. End the chapter with three sentences: what the evidence establishes, what it does not establish and what observation would change the conclusion. This keeps the lesson useful when the browser, context or platform state changes. A strong record also names the datum, denominator, section or coordinate system that governed the decision, so a later reader can repeat the reasoning without importing an unstated shortcut.
Previous chapter · Contents · Next chapter
14. Protect privacy and resources
Background work can reveal activity patterns and consume data or battery. Batch only necessary work and avoid repeated prompts or hidden tracking.
Original worked example. The app syncs user-authored messages but defers large optional attachments to a visible foreground control. The objects, values and observations are explicit so the reader can reconstruct the decision instead of trusting a label.
Changed-context transfer. Switch to metered connectivity and verify the declared policy. State what changed, predict the consequence and revise only the conclusion that depended on that condition.
Practical evidence check. Audit payload minimisation, retention, authentication, frequency and notifications. If this check fails, mark the claim unavailable and repair the method before continuing.
Use a positive case, a clean negative case and an unavailable case. Unavailable evidence means the required field could not be established.
Before closing, reconcile the original fixture against the chapter rule: identify the relevant objects, state, event order and missing evidence; change one condition and mark the first unsupported inference. Preserve the raw trace beside the revised result. End the chapter with three sentences: what the evidence establishes, what it does not establish and what observation would change the conclusion. This keeps the lesson useful when the browser, context or platform state changes. A strong record also names the datum, denominator, section or coordinate system that governed the decision, so a later reader can repeat the reasoning without importing an unstated shortcut.
Previous chapter · Contents · Next chapter
15. Repair common shortcuts
Registered does not mean fired, fired does not mean completed, online does not mean reachable, and a fulfilled fetch does not prove server commit.
Original worked example. A blinded timeline contains each false shortcut and asks for the first missing evidence. The objects, values and observations are explicit so the reader can reconstruct the decision instead of trusting a label.
Changed-context transfer. Hide UI status labels and infer only from logs and acknowledgements. State what changed, predict the consequence and revise only the conclusion that depended on that condition.
Practical evidence check. Require tag, event, waitUntil, request and commit fields. If this check fails, mark the claim unavailable and repair the method before continuing.
Change one consequential premise while keeping the rest fixed. Predict the new branch before inspecting it and preserve disagreement.
Before closing, reconcile the original fixture against the chapter rule: identify the relevant objects, state, event order and missing evidence; change one condition and mark the first unsupported inference. Preserve the raw trace beside the revised result. End the chapter with three sentences: what the evidence establishes, what it does not establish and what observation would change the conclusion. This keeps the lesson useful when the browser, context or platform state changes. A strong record also names the datum, denominator, section or coordinate system that governed the decision, so a later reader can repeat the reasoning without importing an unstated shortcut.
Previous chapter · Contents · Next chapter
16. Answer practical questions
Persist first, register once, perform idempotent work under waitUntil, validate acknowledgement, keep failures pending and provide a manual fallback.
Original worked example. A notes app shows Pending 3 until all three server IDs reconcile, regardless of tag registration success. The objects, values and observations are explicit so the reader can reconstruct the decision instead of trusting a label.
Changed-context transfer. Disable background sync and verify the foreground path uses the same outbox and idempotency keys. State what changed, predict the consequence and revise only the conclusion that depended on that condition.
Practical evidence check. Audit authentication expiry, offline edits, cancellation, retries and visible status. If this check fails, mark the claim unavailable and repair the method before continuing.
Carry one plausible alternative through the state ledger, then choose the next observation that separates it from the leading account.
Before closing, reconcile the original fixture against the chapter rule: identify the relevant objects, state, event order and missing evidence; change one condition and mark the first unsupported inference. Preserve the raw trace beside the revised result. End the chapter with three sentences: what the evidence establishes, what it does not establish and what observation would change the conclusion. This keeps the lesson useful when the browser, context or platform state changes. A strong record also names the datum, denominator, section or coordinate system that governed the decision, so a later reader can repeat the reasoning without importing an unstated shortcut.
Previous chapter · Contents · Next chapter
17. Build a reproducible sync ledger
The ledger should cross outbox commit, worker state, tag state, event, lastChance, request, server commit and local deletion.
Original worked example. Ten rows cover first attempt, transport failure, 503, lost response, duplicate replay and final success. The objects, values and observations are explicit so the reader can reconstruct the decision instead of trusting a label.
Changed-context transfer. Change one failure point per row and predict what remains pending. State what changed, predict the consequence and revise only the conclusion that depended on that condition.
Practical evidence check. Archive harmless payloads, timestamps, raw errors and server test logs. If this check fails, mark the claim unavailable and repair the method before continuing.
Name the handle, registration, event, manifest or browsing context involved. Similar visible results can come from different platform paths.
Before closing, reconcile the original fixture against the chapter rule: identify the relevant objects, state, event order and missing evidence; change one condition and mark the first unsupported inference. Preserve the raw trace beside the revised result. End the chapter with three sentences: what the evidence establishes, what it does not establish and what observation would change the conclusion. This keeps the lesson useful when the browser, context or platform state changes. A strong record also names the datum, denominator, section or coordinate system that governed the decision, so a later reader can repeat the reasoning without importing an unstated shortcut.
Previous chapter · Contents · Next chapter
18. Use the drafts and continue
The Background Sync report defines an opportunity and retry model, while Service Workers define the event host. Neither turns registration into a receipt.
Original worked example. The final report states draft and limited-support status and dates every scheduling observation. The objects, values and observations are explicit so the reader can reconstruct the decision instead of trusting a label.
Changed-context transfer. When support or heuristics change, rerun the saved offline and lost-response cases. State what changed, predict the consequence and revise only the conclusion that depended on that condition.
Practical evidence check. Save exact sources, access date, browser, outbox, tags, event ledger and acknowledgements. If this check fails, mark the claim unavailable and repair the method before continuing.
Archive source, fixture, options, events, timestamps, browser version and raw exceptions so another reader can reproduce the conclusion.
Before closing, reconcile the original fixture against the chapter rule: identify the relevant objects, state, event order and missing evidence; change one condition and mark the first unsupported inference. Preserve the raw trace beside the revised result. End the chapter with three sentences: what the evidence establishes, what it does not establish and what observation would change the conclusion. This keeps the lesson useful when the browser, context or platform state changes. A strong record also names the datum, denominator, section or coordinate system that governed the decision, so a later reader can repeat the reasoning without importing an unstated shortcut.
Grouped reading routes
Core route
Companion lessons
- Separating Persisted FileSystemHandles from Persisted File Permissions
- Separating FileSystemHandle isSameEntry() Identity from Name and Kind Equality
- Separating Manifest display Intent from Applied display-mode State
Related specialist lessons
Sources and further study
WICG Web Background Synchronization Draft Community Group Report. Used for the standard definitions, material mechanisms or method limits developed in this lesson.
W3C Service Workers Editor’s Draft. Used for the standard definitions, material mechanisms or method limits developed in this lesson.
The worked examples and transfer checks are developed here and state their own assumptions. The linked sources support the underlying web-platform mechanisms, state and method limits.
Return to contents · Return to The Gold Standard of Websites
