Skip to content
fa
Search Frontend Atlas
Search questions and concepts across the handbook.
Performance & Reliabilityadvanced12 min read

How should a UI behave under slow, failing, or intermittent networks?

Model loading, stale data, retryability, cancellation, and idempotency as explicit product states.

A request can fail because the user is offline, the server is unavailable, a timeout expires or the response is invalid. Those failures do not all mean the same thing, and a single generic error message rarely helps someone recover. A resilient interface models the network state and gives each failure a sensible next step.

A request can fail because the user is offline, the server is unavailable, a timeout expires or the response is invalid. Those failures do not all mean the same thing, and a single generic error message rarely helps someone recover. A resilient interface models the network state and gives each failure a sensible next step.

The quick version

A resilient UI communicates what is happening, preserves useful stale data when safe, retries only retryable operations, and prevents duplicate mutations. Reads and writes require different retry policies.

Build the mental model

Use exponential backoff with jitter for eligible retries, respect Retry-After, and cap attempts/time. Retrying a non-idempotent mutation can duplicate effects unless the server supports idempotency. Avoid retry storms and synchronize cancellation with navigation.

See it in code

const delay = Math.min(maxDelay, baseDelay * 2 ** attempt) * (0.5 + Math.random());

Where it gets tricky

Use bounded retries with exponential backoff and jitter, honor Retry-After, and stop retrying when the user cancels or the request is no longer relevant. A timeout is not proof that the server did not commit a mutation. Reads are often safe to retry; writes require idempotency or a status-reconciliation endpoint before replay.

A common misunderstanding

“Retry on every error” can amplify outages and duplicate writes.

What this changes in an application

Design explicit offline, timeout, rate-limit, conflict, and authentication-expired states. Preserve user input and make retry scope visible.

Questions worth exploring next

  • Which status codes are retryable?
  • How should a client react to 429 and 503?

References and next steps

  • Retry-After header — primary or authoritative documentation for the underlying behavior.
  • MDN Web Docs — use the relevant API reference for adjacent browser details.