Why is Chrome issuing a “Reapply form submission confirmation” even when I use the PRG template?

After processing the POST request, I do a very standard redirect to the same page so that the user does not get the "Confirm form re-fill" dialog box (or equivalent) if they reload the page.

I am using response status code 303.

Here is the code:

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

This works in both Safari and FF. Chrome opens the "Resubmit Form Confirmation" dialog box.

In Chrome, I can use the network inspector to make sure that the 303 redirect is indeed released, and there is a GET after my initial POST.

However, if I try to reload the page at this point, I get a "Re-form confirmation form".

If I change the URL by adding a fake request parameter, this will not happen. It...

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

... works great.

Is Chrome too smart and momentary to reload the same page? Or is this a known issue? I spent some time looking around, but apart from a million times when people just needed to use the PRG template, nothing.

+7
source share
4 answers

This seems to be a bug in Chrome 25. I tested it in a virtual box with Chrome 24 and upgraded to Chrome 25.

Chrome 24 => No dialogue

Chrome 25 => Dialog

Perhaps you should indicate an error. :-)

+10
source

You can try proxy redirection to a script with a different URI

 if ($_SERVER['REQUEST_METHOD'] == 'POST') { header('Location: proxy.php?uri='.$_SERVER['REQUEST_URI'], true, 303); } 

then come back

 # proxy.php if (!empty($_GET['uri'])) { // maybe some validation here header('Location: '.$_GET['uri'], true, 303); } 
0
source

When a user tries to recover pages that were unexpectedly closed, the browser will display this error "err_cache_miss". Watch the video for the main source of the error https://www.youtube.com/watch?v=6c9ztzqlthE

0
source

it will help you better just put it in any file that includes all files

 header("Cache-Control: no-cache, must-revalidate"); 

if not, try this

 session_cache_limiter('private, must-revalidate'); session_cache_expire(60); 
-one
source

All Articles