How to clear the WebView2 cache?

We are using HTMLExe to package some online course materials that use local browser storage to save state data between sessions. When running native in the web browser we can simply clear cache or open an incognito window to clear this and reset back to default state. With HTMLExe we do not know how to clear it. From MS documentation, the default storage location is the folder the EXE file is running in + .WebView2 but we do not find any new file or subfolder being created in the runtime folder. How can we force clearing cache or locate the cache file location so we can delete it directly?

We solved this by simply calling localStorage.clear() and window.location.reload(true).

1 Like

You can use the built-in button to clear all. Might be what you are looking for:

1 Like