-
Notifications
You must be signed in to change notification settings - Fork 14
Description
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:
CDPedia/src/web/templates/cdpedia_base.html
Lines 27 to 31 in 61f73b4
| {% if watchdog %} | |
| <!-- Watchdog iframe --> | |
| <iframe src="/watchdog/update" style="width:1px;height:1px;display:none;"></iframe> | |
| <!-- /WatchDog iframe --> | |
| {% endif %} |
This iframe requests a dummy empty page that reloads itself every x seconds:
Lines 254 to 261 in 61f73b4
| def on_watchdog_update(self, request): | |
| self.watchdog.update() | |
| seconds = str(int(config.BROWSER_WD_SECONDS * 0.85)) | |
| html = ( | |
| "<html><head><meta http-equiv='refresh' content='%s'></head><body></body></html>" % ( | |
| seconds,)) | |
| resp = Response(html, mimetype="text/html") | |
| return resp |
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.