Post-redirect-get pattern not followed with validation errors

The examples in the Cake documentation follow the post-redirect-get pattern which allow users to hit the browser back button and avoid the dreaded Confirm Form Resubmission browser message. However, the pattern is not followed when there are validation errors. See sample code below:

if($this->Model->save(){
$this->redirect();
} else {
$this->Flash->error(‘Missing fields’);
}

Following the above example allows the browser to display the flash message as well as highlight the fields that cause the error. If I add a redirect after the validation error, then I would be following the post-redirect-get pattern but validation would not work because I lose the individual field messages.

I could probably come up with some hacky custom session solution to get this to work but Im hoping there is a “Cake” way to handle this. My users are notorious for hitting the browser back button and if they had a validation error on the page, but then fixed it and got redirected to the next page, when they hit back, they get the ugly browser message.

Anybody else see this as a problem and found a solution?

Some problem here! No way to fix this…

I find a solution, im sure there a bettere solution but this one works for me:

change the header in layout/default.php

// prevent Confirm Form Resubmission
header(“Cache-Control: no-cache, must-revalidate, post-check=0, pre-check=0”);

cake set the header with no-store before no-cache