Home > database >  How to auto-refresh a web page, even if server returned an error?
How to auto-refresh a web page, even if server returned an error?

Time:09-22

I have an HTML JS web page, which uses http-equiv="refresh" to auto-refresh itself every few seconds. However, sometimes the server returns a 502 "bad gateway" error, so the HTML code is not loaded to the client and thus this auto-refresh does not work any more. However, mnanually refresing the page via F5 in the browser does correctly reload the page.

Now I would like to make this page a bit more robust by allowing itself to refresh, even after a 502 error has been returned. So in other words, the client should try to reload the HTML page after X seconds, in any case.

Is there any way to achieve this kind of auto-refreshing, even if the server does return an error instead of the real HTML page?

CodePudding user response:

I found a solution. For the records:

The page content (everything within the <body> tags) has been moved into another page, which is displayed on the main page (wrapper) via an iframe. That wrapper page itself does the reloading via JS.

  • Related