
Somebody fills in a form, submits it, reads the confirmation, and presses the back button because that is how people get back to where they were. Instead of the form, they get a page headed “Confirm Form Resubmission”, with a button offering to reload and a tone that suggests they have done something wrong.
They have not done anything wrong, and neither has the browser. What they have found is a gap between how your application answered their request and how the browser is allowed to repeat it.
It is worth ten minutes because the fix is three lines on the server, the symptom is entirely on the user’s side, and almost nobody who builds the form ever sees the screen.
The code underneath says something different
Behind that page is a network error, and it is not the one you would guess. Chromium’s own list of network errors gives it as:
The cache does not have the requested entry.
That is ERR_CACHE_MISS, number -400, and the wording repays attention. The screen talks about
forms. The code talks about the cache. Neither of them mentions the thing that actually happened,
which is that the browser was asked to show a page it can only produce by sending your user’s
form a second time.
Why the browser refuses to do that quietly
This is the part that makes the behaviour correct rather than annoying.
A form submission is almost always a POST, and MDN’s reference lists the three properties that
matter here plainly: POST is not safe, not idempotent, and cacheable “only if freshness
information is included”.
Not idempotent is the one that decides this. MDN spells out what it means with the example
everybody has lived through: “Successive identical POST requests may have additional effects,
such as creating the same order several times.”
So when your user presses back, the browser has a choice between showing nothing and silently placing a second order. It declines to choose on their behalf and asks. Put that way, the screen nobody likes is the browser behaving better than the application did.
The cache half of it follows from the same list. Because a POST response is cacheable only when
the server says so explicitly, the page your user is trying to return to was almost certainly
never stored. There is nothing to go back to. Hence a cache miss, reported in the vocabulary of
the cache rather than the vocabulary of the form.
The fix is on the server, and it is old
The pattern has a name: post, redirect, get. Rather than answering a POST with the page you
want the user to read, answer it with a redirect to a page they can GET.
MDN’s description of 303 See Other is precise about what that buys you. The method “to retrieve
the redirected resource is always GET”, and the status is “often sent back as a result of PUT
or POST methods so the client may retrieve a confirmation”.
That last clause is this exact situation. The user’s browser sends the POST, your server
processes it and answers 303 with a Location, the browser fetches that location with a GET,
and the page the user ends up looking at is an ordinary addressable page. Pressing back now
re-runs a GET, which the browser may repeat as often as it likes, because a GET does not
create orders.
- Answering the POST directly
- The confirmation page has no address of its own. Back offers to resubmit, reload breaks, and the URL cannot be shared or bookmarked
- POST, then 303, then GET
- The confirmation has a real URL. Back, reload, bookmark and share all behave, and nothing the user does can place a second order
Not 302, and definitely not 307
Three redirect codes look interchangeable here and are not.
307 Temporary Redirect is, in MDN’s words, “a temporary redirect where the request method is
not modified”. After a POST that is precisely wrong: the browser follows it by sending the
POST again, to a different URL, and you have built the duplicate submission you were trying to
prevent.
302 Found is described as “a temporary redirect” with nothing said about the method, and its
handling by real clients has been inconsistent for long enough that relying on it is a choice
rather than an assumption.
303 is the one that states the rule out loud. Use it after a form.
Why this reaches you as a report you cannot reproduce
You do not press back after submitting a form. You submit the form, see that it worked, and move on to the next thing you were testing. Your users press back constantly, because for them the form is not a test case, it is the middle of something they were doing.
So the report arrives as a complaint about a screen you have never seen, in words that do not contain any of the terms you would search for. “It said something about resubmission.” “I pressed back and it broke.” Neither is wrong and neither tells you which form, which page, or what the browser was actually asked to do.
Session Replay
Free Chrome extension. One click on the page that is misbehaving captures the screenshot, the console and the network log, and hands you a link to paste into the ticket.
The two useful things to ask for are the screen itself and the address bar, because the URL is
what says whether the page was reached by a GET or is the undisplayable answer to a POST. A
confirmation page whose URL is the same as the form’s action, with nothing identifying the thing
that was just created, is the shape of this problem before anybody has looked at the server.
What to take from it
A browser showing “Confirm Form Resubmission” is reporting an architectural decision, not a
fault. Somewhere an application answered a POST with a page it expected people to stay on, and
people do not stay on pages.
The three facts worth keeping:
- The underlying code is
ERR_CACHE_MISS, which is why searching the screen’s own wording finds so little that is useful. -
POSTis not idempotent, so the browser will not replay it without asking, and that is the behaviour you want. - Answering a form with
303and aLocationremoves the screen, and it also gives the confirmation a URL that can be reloaded, bookmarked and shared.
Chromium’s list of these errors, with the one-line definition of each, is net_error_list.h, and it is the source the error pages are generated from.