Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
Need an API to clear WebView cache/stored passwords #33
I'm submitting a...
WebView class does not provide a method to clear cache.
Clear method in WebView to clear cache
Minimal reproduction of the problem with instructions
Suppose you need to clear cached aspx pages to fetch them from server, there is no exposed method to achieve it.
WebView uses the same WinINET cache the UWP HttpClient uses... Which doesn't let you clear it's cache. (Unless you break outside the sandbox). You can optionally use a custom HttpRequestMessage during navigation with custom cache headers if the server responds to them properly.
It might help devs who missed the no-cache headers initially. If you remove the specific cached files located in C:\Users\AppData\Local\Packages\Microsoft.Win32WebViewHost_cw5n1h2txyewy\AC
Me too! Although Windows.UI.Xaml.Controls.WebView.ClearTemporaryWebDataAsync exists, this
@purani asked about clearing stored passwords. I haven't checked whether
If you use WebViewControlProcess and you terminate your instance and start up a new process/instance, what happens to session state, cookies, passwords?
What's the best way to clear everything in WebView on a shared computer before a different person starts using the computer? To switch to a different person, cookies and passwords need to be deleted, but it's not strictly necessary to delete cached HTML pages, JPEG files, etc. However for extra security, it's good to have the option to also delete all cached files.
The following was a technique for Internet Explorer. Should it be used in conjunction with WebView? Obviously this is only possible outside of the sandbox, such as when WebView is used in a WPF app.
Here's another ugly hack that was possible with WPF's
InPrivate mode to support multi-user scenarios:
It would be very useful if WebView (both
The idea is that you'd create an "InPrivateSession" object and use the same InPrivateSession instance with multiple WebView instances. When you dispose/end the InPrivateSession instance, it should delete all cookies/sessions/passwords that were created during/inside that InPrivateSession instance. Thus an InPrivateSession would be like a container that stores or records all cookies/sessions/passwords created in or during that InPrivateSession and deletes them when the InPrivateSession is disposed/ended. In other words, when a WebView is linked with an InPrivateSession instance, then the lifetime of new cookies should be limited to the lifetime of the InPrivateSession instance.
Regarding deletion of cached webpages, image files, etc, ideally this would be optional. I'd love to have a setting that controls whether cache and cookies is deleted versus only cookies deleted. The problem with deleting all cached files is that it causes a lot of extra network traffic to repeatedly re-download the same files.
I investigated further. An exception is thrown when I try to invoke the static method
My test app is deliberately kept simple -- it does not create any new threads or dispatchers. I presume the
Package version 6.0.0-preview7. .NET Framework v4.8 running in Windows 10 version 1903 (build 18362.267).
As an ugly workaround/hack until a proper solution is released, is it acceptable to clear WPF WebView's cache (or the whole computer's cache) by using P/Invoke in a WPF app to invoke
To delete cookies, how about:
Re the aforementioned