Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Prevent browser from repeating long post requests

Tags:

browser

ajax

http

According to the HTTP 1.1 spec, browsers should retry a request if they pass a certain time limit or if an error response is received. POST requests are no exception.

Occasionally, slow connections combined with a processor heavy request can cause an ajax POST request to time out, and the browser will fire a second POST request with the same data. This leads to unexpected and erroneous behaviors. Is there any way to prevent that browser timeout from triggering and firing a second POST request?

like image 439
Seamus James Avatar asked May 17 '16 21:05

Seamus James


1 Answers

Based on my understanding you can't restrict the client to stop automatic retries. The best option is to handle the identical requests in the server side by using unique GUID's. https://blogs.oracle.com/ravello/beware-http-requests-automatic-retries/comment-submitted?cid=b956dee8-7352-4d88-ad40-71ff9fd1eb53

like image 141
excitepv Avatar answered Oct 26 '22 04:10

excitepv