Why is my mobile browser resubmitting POST data silently?
Asked by
Nutmegger
I've set up a simple survey page for my village, and I've been noticing that some users are having their POST submissions resubmitted without meaning to. Typically, when you go back to a page that requires a POST submission, the browser prompts you to resend data. However, users are reporting that after submitting the survey, if they navigate away and then return to the confirmation pageโwhich has the same URLโthey receive a message saying they've already submitted their data. This makes me think the browser is resubmitting the POST silently when revisiting the result page, which seems unexpected. Am I missing something? Is this behavior common nowadays?
Answers
Actually, if youโre using standard HTML form submission, refreshing the page can resend the POST request because the URL still contains valid form data. This is quite normal behavior, especially on mobile browsers, which might handle session history differently than desktop ones.
Reply to this answer
One very straightforward solution is to redirect users after they submit the form. Even if it's to the same URL, just ensure it's GET. This way, if users hit back or refresh, they won't trigger a POST resend.
Reply to this answer
It sounds like you're running into the classic Post/Redirect/Get (PRG) issue. When a user submits a form and then gets redirected, that helps avoid silent resubmissions. If you handle the POST submission by redirecting them to another page or even reloading the same URL with a GET request, that should solve the problem. It's a common pattern to implement for forms!
Reply to this answer
Add your answer
Answers are reviewed before publication.
Related Discussions