Search code examples
javarestapipostget

Is rest POST Api automatically retry by browser like Get Api?


We have a GET Api that do some operation and returns a long JSON ( assume total response size is 1 mb) .

When client requests GET API , this API took around five mins to do the Operation . But browser retry the GET API after two mins .

My question is

  1. If I change the Get API to post , So browser wont retry the request right?
  2. Is the timeout behaviour of post Api also same as GET Api ?
  3. Is the any limit for the response size we are sending in POST API response ?

Note : I know Post API is not the right one , we are doing this work around temporarily

Thanks in advance


Solution

    1. I don't know about a retry that is done by browsers. Is it maybe a client-side library or a proxy in between client and server that does the retry? GET is meant to retrieve information (RFC 2616). It must be safe and idempotent (RFC 2616). So, a second GET can be expected to cause no damage. This is not true for POST. So, you can expect that no retry will happen by any HTTP-agent when using POST.
    2. You have to find out where the retry comes from to get an answer.
    3. I don't think so, have never heard of one. The request might be a different matter.

    You have to be aware that such a long-running request could face further problems. A corporate firewall could close the TCP-connection after some time of inactivity for example. An asynchronous handling could be worth considering. I mean to save the result on server and let the client retrieve it in a later request. This also avoids irritated users. Users that click again and again because it takes so long (the human retry) can slow down your server.

    By the way, configuring compression on the server usually reduces the payload of messages quite a lot in case of JSON.