diff --git a/controller/Changelog.md b/controller/Changelog.md index 4120774c..c1b9c491 100644 --- a/controller/Changelog.md +++ b/controller/Changelog.md @@ -2,6 +2,7 @@ ## Added +- kiosk: Add a key combination to perform hard refresh (Ctrl-Shift-R) - os: Added localization options for Polish and Czech # [2023.9.0] - 2023-09-12 diff --git a/docs/user-manual/Readme.org b/docs/user-manual/Readme.org index beeea1b1..ef93a0bd 100644 --- a/docs/user-manual/Readme.org +++ b/docs/user-manual/Readme.org @@ -131,6 +131,10 @@ View what has been added, changed and fixed with each version. A status screen providing a brief status report about various components of the system is available on ~tty8~. It can be accessed using the key combination ~Ctrl-Alt-F8~. To get back from the status screen to the graphical interface, use ~Ctrl-Alt-F7~. +** Clearing kiosk browser cache + +At times network issues may cause corrupted media resources to end up in the kiosk browser's cache. In this case it may be helpful to clear this cache to force all resources being downloaded again. A hard refresh can be triggered using ~Ctrl-Shift-R~, which clears the cache and then reloads the kiosk application. The hard refresh does not affect user sessions or preferences, so it can be performed without the user having to log in again. + ** Wiping user data Certain user data such as Play login credentials, wireless settings are stored persistently on the computer's disk. diff --git a/kiosk/kiosk_browser/browser_widget.py b/kiosk/kiosk_browser/browser_widget.py index f62a4a19..d494c5d8 100644 --- a/kiosk/kiosk_browser/browser_widget.py +++ b/kiosk/kiosk_browser/browser_widget.py @@ -2,6 +2,7 @@ from enum import Enum, auto import logging import re +import time from kiosk_browser import system @@ -59,8 +60,11 @@ def __init__(self, url, get_current_proxy, parent): self._webview.loadFinished.connect(self._load_finished) # Shortcut to manually reload - self.reload_shortcut = QtWidgets.QShortcut('CTRL+R', self) - self.reload_shortcut.activated.connect(self.reload) + self._reload_shortcut = QtWidgets.QShortcut('CTRL+R', self) + self._reload_shortcut.activated.connect(self.reload) + # Shortcut to perform a hard refresh + self._hard_refresh_shortcut = QtWidgets.QShortcut('CTRL+SHIFT+R', self) + self._hard_refresh_shortcut.activated.connect(self._hard_refresh) # Prepare reload timer self._reload_timer = QtCore.QTimer(self) @@ -93,6 +97,23 @@ def _load_finished(self, success): self._view(Status.NETWORK_ERROR) self._reload_timer.start(reload_on_network_error_after) + def _hard_refresh(self): + """ Clear cache, then reload. + + Does not affect cookies or localstorage contents. + + NOTE This clears the entire HTTP cache, assumed to be OK as the kiosk targets a specific page. + """ + logging.info(f"Clearing HTTP cache (hard refresh)") + self._webview.page().profile().clearHttpCache() + + # Sleep before triggering reload to avoid a possible race condition. + # Future Qt versions may provide a signal on `QWebEngineProfile` to + # allow to queue the reload on clear-cache completion instead. + # https://bugreports.qt.io/browse/QTBUG-111541 + time.sleep(0.25) + self.reload() + def _proxy_auth(self, get_current_proxy, url, auth, proxyHost): proxy = get_current_proxy() if proxy is not None and proxy.credentials is not None: