<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[disable network cache in iOS]]></title><description><![CDATA[<p dir="auto">In my code I'm using HTTP get to communicate with a server. It appears that QNetworkAccessManager uses cache to return previously fetched data even if the device is offline. This behaviour seems to be specific to iOS. Here is my code:</p>
<pre><code>	QNetworkRequest request;
	request.setUrl(QUrl(urlStr));
	request.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::AlwaysNetwork);
	request.setAttribute(QNetworkRequest::CacheSaveControlAttribute, false);
	m_reply = networkManager()-&gt;get(request);
    connect(m_reply, &amp;QNetworkReply::finished, this, &amp;CServerCommunicator::onLoginFinished);
</code></pre>
<p dir="auto">If urlStr has been fetched previously and the device is offline, m_reply emits <code>finished()</code> with no error and contains cached data. On any other platform than iOS it finishes with network error as expected (I tried OS X, Ubuntu and Android).<br />
What else can I try to disable network cache in iOS? I'm also calling <code>networkManager()-&gt;cache()-&gt;clear();</code> when my app is closing, but it also has no effect at all.</p>
]]></description><link>https://forum.qt.io/topic/54889/disable-network-cache-in-ios</link><generator>RSS for Node</generator><lastBuildDate>Mon, 06 Apr 2026 05:26:16 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/54889.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 04 Jun 2015 12:55:48 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to disable network cache in iOS on Tue, 09 Jun 2015 08:16:23 GMT]]></title><description><![CDATA[<p dir="auto">Surprisingly, I was able to fix this by clearing the native iOS cache:<br />
<code>&lsqb;&lsqb;NSURLCache sharedURLCache] removeAllCachedResponses];</code><br />
This call has effect on both native iOS networking and Qt network code.</p>
<p dir="auto">In order to use the above call you have to rename your file to *.mm and include &lt;Foundation/Foundation.h&gt;.</p>
]]></description><link>https://forum.qt.io/post/277268</link><guid isPermaLink="true">https://forum.qt.io/post/277268</guid><dc:creator><![CDATA[m_andrej]]></dc:creator><pubDate>Tue, 09 Jun 2015 08:16:23 GMT</pubDate></item><item><title><![CDATA[Reply to disable network cache in iOS on Thu, 04 Jun 2015 15:32:10 GMT]]></title><description><![CDATA[<p dir="auto">The problem persists even if I set my own QNetworkDiskCache to the network manager and clear cache directory:</p>
<pre><code>m_netManager = new QNetworkAccessManager(this);
QNetworkDiskCache *diskCache = new QNetworkDiskCache(this);
diskCache-&gt;setCacheDirectory(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + "/" + QUuid::createUuid().toString());
m_netManager-&gt;setCache(diskCache);
</code></pre>
<p dir="auto">Actually I'm using a different directory each time, which should have the same effect. But no, network manager still returns data as if it were online.</p>
]]></description><link>https://forum.qt.io/post/276730</link><guid isPermaLink="true">https://forum.qt.io/post/276730</guid><dc:creator><![CDATA[m_andrej]]></dc:creator><pubDate>Thu, 04 Jun 2015 15:32:10 GMT</pubDate></item></channel></rss>