I am newbie of backend developer. I am learning PRG (post redirect get) pattern to prevent the resubmit form when user click reload button after submitting the form. I don't understand why click reload button after submitting form cause resubmitting again.Please, tell me the causes of that problem.
When you submit a form with method="POST"
, the browser constructs a POST request and sends it to the server. If the server responds with 200 OK
and an HTML document then the browser will render that HTML document.
The refresh button is a browser feature which lets the user repeat the last request.
Since the last request, in the above scenario, is "a POST request", it causes the browser to repeat the POST request.
In the PRG pattern, the response to the POST request is a redirect which causes the browser to make a GET request.
In this scenario, the the request is "a GET request".