Hi all,

I can't manage to make the cache work with WNAM.
Here is what I did so far :

Qt Code:
  1. MyNetworkManager* manager = new MyNetworkManager(parent);
  2. QNetworkDiskCache* diskCache = new QNetworkDiskCache(parent);
  3. QString dataPath = QDesktopServices::storageLocation(QDesktopServices::CacheLocation);
  4. diskCache->setCacheDirectory(dataPath);
  5. diskCache->setMaximumCacheSize(5*1024*1024); // 5Mo
  6. manager->setCache(diskCache);
To copy to clipboard, switch view to plain text mode 

MyNetworkManager is very simple and redefines :

Qt Code:
  1. QNetworkReply *
  2. MyNetworkManager::createRequest( Operation op, const QNetworkRequest & req, QIODevice * outgoingData)
  3. {
  4. QNetworkRequest request(req);
  5. request.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::PreferCache);
  6. return QNetworkAccessManager::createRequest(op, request, outgoingData);
  7. }
To copy to clipboard, switch view to plain text mode 

I use this manager in a Symbian QML application. I can see all requests goes through my createRequest function, which is fine.
I can also see that .cache files are created in the cache directory and they contains the responses data.
However, when I switch the internet connection off, the manager does not return cached data.

What am I doing wrong here ? Can somebody point me on a working exemple of using cache with QNAM (preferably with QML but pure Qt is also ok).

Thank you for your help !

Rémy