Quantcast
Channel: Question and Answer » web-services
Viewing all articles
Browse latest Browse all 136

How to Handle Duplicate Web Requests on Server

$
0
0

I’m running a Twisted web server and trying to figure out a good way to handle retries from the client. In normal operation the client makes a request of the server with some JSON data and receives a JSON response. Every request includes a header with a unique identifier.

I’m trying to handle the case where the client doesn’t receive the response (might time out) and needs to resubmit the request. Since the request can change the server state I don’t want it to reprocess if it’s already been processed.

Possible approaches:

  • What I’m thinking of is caching every JSON response and if the client
    submits a request with a duplicate request ID then just return the cached
    data. The thing is I’m not sure how often this situation will
    actually come up in the wild and caching every response and
    inspecting every request might be a lot of overhead (some responses
    are quite large JSON structures).

  • I could minimize much of the caching by just returning a HTTP response
    that indicates it was a duplicate request, but then the client won’t know
    what the original response was.

Is there a best-practice for handling duplicate requests from a server?


Viewing all articles
Browse latest Browse all 136

Trending Articles