Skip to content
This repository has been archived by the owner on Nov 1, 2022. It is now read-only.

Latest commit

 

History

History

request-deferrer

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 

Request Deferrer

This recipe shows how to enqueue requests while in offline in an outbox-like buffer to perform the operations once the connection is regained.

Difficulty

Advanced

Use Case

As a modern framework developer, I want to provide an agnostic way of handling requests while offline.

Solution

Use a Service Worker to intercept requests. While offline, record the successive requests in a queue to preserve the order and answer with fake responses. If online, flush the queue to replay the session and sync with the server.

This advanced technique is intended to integrate with REST APIs and it requires the client to deal with asynchronous create (POST) operations (HTTP answering with status code 202, Accepted).

The solution is a proof of concept and does not include error handling which is a real challenge in this implementation. Some of the problems are stated in the inlined documentation.

Category

Beyond Offline