Every time I navigate back to a page where I submitted a (post)form in Chrome, I get a white page displaying the following error: ERR_CACHE_MISS
I did some searching but couldn't find any real solution to this problem.
How can I prevent this error?
Every time I navigate back to a page where I submitted a (post)form in Chrome, I get a white page displaying the following error: ERR_CACHE_MISS
I did some searching but couldn't find any real solution to this problem.
How can I prevent this error?
I solved this issue using the trick. When POST data detected make another reload using header location (GET method). Back button is now redirecting to GET instead of POST and problem will not occure.
When U need to use posted data, simple store it into session for next aplication, when index.php is loaded again.
index.php
if (isset($_POST[...
{
// - 1st load
$_SESSION["posted-data"] = $_POST;
header('Location:index.php?pass=...');
}
if (isset($_SESSION["posted-data"]))
{
// - 2nd load
... code to process ...
unset($_SESSION["posted-data"])
}
After POST method the page is loaded twice, but when u parse in the begining of programm, it can not be noticed. You need only to organize data for double assembling. First - parsing incoming and prepare for transmiting after GET reload. (ie using SESSION).
It might not be the best solution but I used Javascript to prevent this error from appearing.
I added history.replaceState({}, '', 'yourPage.php'); to the onclick="" attribute of the submit button, see this example:
<form action="yourPage.php" method="post">
<input type="hidden" name="value" value="someValue">
<input type="submit" name="sumitForm" onclick="history.replaceState({}, '', 'yourPage.php');" value="Pas aan">
</form>
What this does is it replaces the last page in your browser history with this page, so that when you navigate back yourPage.php will be called and the ERR_CACHE_MISS error does not appear anymore.
In case the current page could contain get variables you could use history.replaceState({}, '', document.referrer); instead.
Any suggestions/better solutions are welcome...