The CacheStorage interface provides methods for clearing cache. Cache is cleared asynchronously, so when any of those methods return, it does not mean that all cache data is cleared completely.


To clear the cache and get a notification when cache data is cleared completely you should use the ClearCache(Action onCacheCleared) method.


The following code demonstrates how to clear cache and set up an action which will be run when the cache is cleared successfully:

C#

browser.CacheStorage.ClearCache(()=> 
{
    Console.WriteLine("The cache is cleared");
});

VB.NET

browser.CacheStorage.ClearCache(Sub() 
    Console.WriteLine("The cache is cleared") 
End Sub)



Since DotNetBrowser 1.18, it is possible to clear the HTTP authentication cache and gets a notification when the data is cleared completely using the ClearHttpAuthenticationCache(Action onHttpAuthCacheCleared) method.


The following code demonstrates how to clear HTTP authentication cache and set up an action which will be run when the data is cleared successfully:

C#

browser.CacheStorage.ClearHttpAuthenticationCache(()=> 
{
    Console.WriteLine("The HTTP authentication data is cleared");
});

VB.NET

browser.CacheStorage.ClearHttpAuthenticationCache(Sub() 
    Console.WriteLine("The HTTP authentication data is cleared") 
End Sub)