Retry XMLHttpRequest Carefully

It’s rare to see a web app that doesn’t use XMLHttpRequest (or fetch, the new API with comparable capability). XMLHttpRequest (which we can call XHR if you’re into the whole brevity thing) is as handy as a shirt pocket, but it doesn’t do much to encourage robust and resilient programming practices. Any app that runs in the real world will sometimes encounter transient network interruptions and server outages. We should gracefully recover from both by automatically retrying our requests. But, we shouldn’t turn a brief server hiccup into a full-on fireworks display by retrying too fast or by having every client retry at the same time.

3 Likes

Corresponding tweet for this thread:

Share link for this tweet.

2 Likes