Watchdog timer broken when using browser's back button
Issue reproduction
- start CDPedia
- navigate to an article
- return to the first page by pressing the browser's back button
- wait at least 2 minutes and try to navigate to another article
- the browser can't connect to CDPedia because the process ended
This is unexpected. The process should not be terminated while there's a CDPedia page opened in the browser.
Current behaviour
The current watchdog mechanism is implemented by embedding an iframe in each page:
https://github.com/PyAr/CDPedia/blob/61f73b4295151aa55b17e3577f31664f129403bd/src/web/templates/cdpedia_base.html#L27-L31
This iframe requests a dummy empty page that reloads itself every x seconds:
https://github.com/PyAr/CDPedia/blob/61f73b4295151aa55b17e3577f31664f129403bd/src/web/web_app.py#L254-L261
CDPedia will exit if more than BROWSER_WD_SECONDS seconds pass without hitting this endpoint.
This works great for all situation except the one described above.
Possible solutions
Adding {"Cache-Control": "no-cache, no-store, must-revalidate"} to the response headers of the watchdog endpoint fixes the issue in Chrome but not in Firefox. Maybe a solution with javascript should be explored.