I have a completely properly configured behavior problem for 500 internal server error pages.
I have two main uses:
No header sent
Fix it here is easy, just throw 500 500 errors without changing the URL. .
Partial page error
In this case, some HTML & amp; HTML headers were already sent to the customer To prevent partially broken pages from displaying, I redirect the output JavaScript completely to an error page URL, /error.html. This is to avoid displaying any normal page and part of an error page, and it clarifies that the resultant HTML is not optimal, even though the error message is being displayed in that section, is currently hidden. , A dedicated error page.
Unfortunately, while hitting the "back" from the dedicated error page, the original error page is cached, and javascript redirection is redistributed, even if the error is fixed during this time.
For example, if there is an error after sending headers in index.php, then there will be JavaScript output that will redirect the user to /error.html. Once, they can return to the homepage (which should be OK), or hit back when they come back, they can get a cached page which redirects them to error.html. Index.php & gt; Error.html (back hit) cached index.php> Error.html
What is the ideal way to avoid this situation?
In the code given below, I try to redirect the #Har hash to the URL only for the first time, and 60 seconds refresh attempt cycles are started on a broken partial page tour. . Unfortunately, when I set #error hashes and redirects, then hit back, it goes to index.php, index.php is not error #, so there is a cached infinite loop.
How Do I Get Partial Page 500 Errors?
The code in my PHP custom error handler, which causes the above listed behavior:
function showErrorPage () {if (headers_sent ()) {// The header is already complex due to the infastructure sent ... ... ... in many instances a tuned JavaScript redirect is required // the following output as html // ? & Gt; & Lt; Meta http-equiv = "cache-control" content = "no-cache, no-store" & gt; & Lt; Script type = 'text / javascript' & gt; Var currentHash = location.hash; // Unfortunately, even the set does not appear! If (! CurrentHash) {// If the hash was not already set ... location.hash = '#error'; Location.href = 'error.html'; // Once again Directly] Else {// Otherwise, the hash was already set, they were redirected once, but came back to // just display this page for a time, but Refresh slow schedule SetTimeout (function () {location.reload (true); // non-caching refresh.}, 60 * 1000); // Reload after a 1 minute delay} & lt; / Script & gt; & Lt ;? Php} else {// no headers have been sent, so set the correct header header ("HTTP / 1.1 500 internal server error"); Header ("Cash-Control: No-Cash, Just-Recallidate"); // HTTP / 1.1 header ("End: Saturn, 26 July 1997 05:00:00 GMT"); // date in the past} // Include the error, output error and exit with error. Includes (WEB_ROOT.'error.html '); Exit (1); }
I have found a useful solution, which is as follows:
By javascript, hide all sections of the page and replace them with an error message in a div. Specifically, I wrote directly to the HTML, hid it, cloned it, cloned it, removed all the elements of the body, and the attachment removed the error divisor to the body, making it the only thing to appear on the page Otherwise there are plenty of site elements on it except in general.
Comments
Post a Comment