Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is Chrome issuing a "Confirm Form Resubmission" even when I'm using the PRG pattern?

After processing a POST request I am doing the very standard thing of redirecting to the same page so that the user won't get a "Confirm Form Resubmission" (or equivalent) dialog if they reload the page.

I am using a 303 response status code.

Here's the code:

header( "HTTP/1.1 303 See Other" );
header( "Location: " . $_SERVER['REQUEST_URI'] );
exit();

This works as expected in Safari and FF. Chrome pops up the "Confirm Form Resubmission" dialog.

In Chrome I can use the network inspector to see that the 303 redirect is indeed issued and there is a GET following my initial POST.

Yet if I try to reload the page at that point I get the "Confirm Form Resubmission".

If I modify the URL by adding a spurious query param, this does not happen. That is...

header( "HTTP/1.1 303 See Other" );
header( "Location: " . $_SERVER['REQUEST_URI'] . '?foo' );
exit();

...works just fine.

Is Chrome trying to be too clever and short-cutting the reload of the same page? Or is this a known issue? I've spent some time looking around, but aside from a million cases of people just needing to use the PRG pattern, nothing.

like image 954
Greg Avatar asked Feb 23 '13 02:02

Greg


1 Answers

This seems to be a bug in Chrome 25. I tested it in virtualbox with Chrome 24 and updated to Chrome 25.

Chrome 24 => No dialog

Chrome 25 => Dialog

Maybe you should file a bug. :-)

like image 180
Oliver Avatar answered Nov 10 '22 08:11

Oliver