gpt4 book ai didi

caching - Xamarin iOS 从 WKWebView 清除缓存

转载 作者:行者123 更新时间:2023-12-02 21:04:06 32 4
gpt4 key购买 nike

我正在执行以下操作来清除 WkWebView 中的缓存。我想知道如何确认缓存已清除

 var request = new NSUrlRequest (webURL, NSUrlRequestCachePolicy.ReloadIgnoringLocalAndRemoteCacheData, 0);

NSUrlCache.SharedCache.RemoveAllCachedResponses ();
NSUrlCache.SharedCache.MemoryCapacity = 0;
NSUrlCache.SharedCache.DiskCapacity = 0;

有没有办法在发出请求时打印缓存

最佳答案

从此question看起来你为 iOS 9 执行此操作(c# 版本),它将打印出哪些记录被删除:

var websiteDataTypes = new NSSet<NSString>(new []
{
//Choose which ones you want to remove
WKWebsiteDataType.Cookies,
WKWebsiteDataType.DiskCache,
WKWebsiteDataType.IndexedDBDatabases,
WKWebsiteDataType.LocalStorage,
WKWebsiteDataType.MemoryCache,
WKWebsiteDataType.OfflineWebApplicationCache,
WKWebsiteDataType.SessionStorage,
WKWebsiteDataType.WebSQLDatabases
});

WKWebsiteDataStore.DefaultDataStore.FetchDataRecordsOfTypes (websiteDataTypes, (NSArray records) =>
{
for (nuint i = 0; i < records.Count; i++) {
var record = records.GetItem<WKWebsiteDataRecord> (i);

WKWebsiteDataStore.DefaultDataStore.RemoveDataOfTypes (record.DataTypes,
new[] {record}, () => {Console.Write($"deleted: {record.DisplayName}");});
}
});

或者对于 iOS 8,来自 ShingoFukuyama/WKWebViewTips您可以检查Library目录中的子目录Cookies、Caches、WebKit是否已被删除。

iOS 8

After much trial and error, I've reached the following conclusion:

Use NSURLCache and NSHTTPCookie to delete cookies and caches in the same way as you used to do on UIWebView.

If you use WKProccessPool, re-initialize it.

Delete Cookies, Caches, WebKit subdirectories in the Library directory.

Delete all WKWebViews

关于caching - Xamarin iOS 从 WKWebView 清除缓存,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36989788/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com