Skip to content

Commit

Permalink
Clear WebEngine's HTTP cache on start-up
Browse files Browse the repository at this point in the history
I noticed that after replacing the JavaScript bundle, WebEngine continues
to use parts of the old code. Clearing the cache fixes this, though it is
a bit heavy-handed.
  • Loading branch information
jitseniesen committed Aug 5, 2024
1 parent e753beb commit 512b52b
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions spyder_notebook/utils/servermanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

# Qt imports
from qtpy.QtCore import QObject, QProcess, QProcessEnvironment, QTimer, Signal
from qtpy.QtWebEngineWidgets import QWebEngineProfile

# Third-party imports
from jupyter_core.paths import jupyter_runtime_dir
Expand Down Expand Up @@ -123,6 +124,10 @@ def __init__(self, dark_theme=False):
"""
Construct a ServerManager.
This constructor also clears Qt WebEngine's HTTP cache, because for
unknown reasons WebEngine seems to use out-of-date code after the
JavaScript bundle is replaced.
Parameters
----------
dark_theme : bool, optional
Expand All @@ -132,6 +137,7 @@ def __init__(self, dark_theme=False):
super().__init__()
self.dark_theme = dark_theme
self.servers = []
QWebEngineProfile.defaultProfile().clearHttpCache()

def get_server(self, filename, interpreter, start=True):
"""
Expand Down

0 comments on commit 512b52b

Please sign in to comment.