【问题标题】:Disable cache in IOS application with UIWebview使用 UIWebview 禁用 IOS 应用程序中的缓存
【发布时间】:2016-01-24 17:44:22
【问题描述】:

我有一个应用程序 IOS,它每 5/10 秒加载相同的 url 但内容不同。 在我的网站上,我计算我的应用程序调用我的网址 websie 的频率。 当我在浏览器中调用我的网站时(safari/chrome/fiefox...) 我的网站计算的好次数。 当我用我的应用程序调用我的网站时。我的网站不计算好次数。比较低。

我认为这是缓存的原因。 如何在 Uiwebview IOS 应用程序上禁用缓存? 我已经在我的代码[[NSURLCache sharedURLCache] removeAllCachedResponses]; 中有我的请求,但我认为这是我加载 UIwebview 的时候。

NSString *html = @"<head></head><body style='padding:0;margin:0;'><script src='http://url_with_content.com'></SCRIPT></body>";
NSString *script = [[NSString alloc] initWithFormat:@"%@", html];
[adView loadHTMLString:script baseURL:nil];

【问题讨论】:

    标签: ios objective-c caching request


    【解决方案1】:

    试试这个:

    // Clear all Cookies and cache
    [[NSURLCache sharedURLCache] removeAllCachedResponses];
    NSHTTPCookie *cookie;
    NSHTTPCookieStorage *storage = [NSHTTPCookieStorage sharedHTTPCookieStorage];
    for (cookie in [storage cookies]) {
        [storage deleteCookie:cookie];
    }
    

    【讨论】:

    • 我测试但我有同样的问题!
    • 你唯一的选择是删除 webview 并创建一个新的。没有用于清除 webview 历史记录的公共 api。
    • 我删除了我的 webview 并创建了一个新的...添加了一个参数 &amp;time=timestamp 以获得不同的 url/html 代码!一样!我不明白!!
    猜你喜欢
    • 2013-06-22
    • 1970-01-01
    • 2011-12-28
    • 2016-01-13
    • 2016-03-07
    • 2017-08-17
    • 2014-10-26
    • 2016-12-07
    • 2012-05-13
    相关资源
    最近更新 更多