Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Highlighted
Developer
Posts: 813
Registered: ‎05-29-2012
My Device: see later
My Carrier: see later
Accepted Solution

QNETWORKACCESSMANAGER avoid caching

QNetworkAccessManager* netManager = new QNetworkAccessManager(this);

		qDebug() << "here1";
		const QUrl url("http://www.google.com/read.json");
		QNetworkRequest request(url);

		QNetworkReply* reply = netManager->get(request);
		bool ok = connect(reply, SIGNAL(finished()), this, SLOT(onReplyFinished()));
		Q_ASSERT(ok);
		Q_UNUSED(ok);

 

 

how can I avoid caching, coz this is working cached

Developer
Posts: 813
Registered: ‎05-29-2012
My Device: see later
My Carrier: see later

Re: QNETWORKACCESSMANAGER avoid caching

if i go out of the app, reuse app after 10 - 15 minutes..it works fine.
but if i do it back to back..i get content cached. i dont want caching.
Developer
Posts: 813
Registered: ‎05-29-2012
My Device: see later
My Carrier: see later

Re: QNETWORKACCESSMANAGER avoid caching

its as if its always working cached now. even if i get back to app after 10 minutes.
Developer
Posts: 813
Registered: ‎05-29-2012
My Device: see later
My Carrier: see later

Re: QNETWORKACCESSMANAGER avoid caching

on replyfinished i do this

 

void ApplicationUI::onReplyFinished()
{
	qDebug() << "here2";
	QNetworkReply* reply = qobject_cast<QNetworkReply*>(sender());


	QString response;
	if (reply) {
		if (reply->error() == QNetworkReply::NoError) {
			const int available = reply->bytesAvailable();
			if (available > 0) {
				const QByteArray data(reply->readAll());
				//	QVariant jsonva(QString(data)); //= Json::parse(QString(data), true);
				// JsonDataAccess json = JsonDataAccess::loadFromBuffer(QString(data));
				JsonDataAccess jda;
				QVariant jsonva = jda.loadFromBuffer(QString(data));
				//QVariantList list = jsonva.toList;
				QVariant list = jsonva;
				emit buildList(list);
				qDebug() << "here3";
			}
		}
		reply->deleteLater();

	}
}

 

Developer
Posts: 813
Registered: ‎05-29-2012
My Device: see later
My Carrier: see later

Re: QNETWORKACCESSMANAGER avoid caching

any ansers on this?
Developer
Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: QNETWORKACCESSMANAGER avoid caching

I might be totally off here but are you sure it's not the ISP or server that's caching the data?


If you've been helped click on Like Button, if you've been saved buy the app. Smiley Happy

Developer of stokLocker, Sympatico and Super Sentences.
Developer
Posts: 813
Registered: ‎05-29-2012
My Device: see later
My Carrier: see later

Re: QNETWORKACCESSMANAGER avoid caching

solved this way

 

request.setAttribute(QNetworkRequest::CacheLoadControlAttribute,
			            QNetworkRequest::AlwaysNetwork);

 

Developer
Posts: 813
Registered: ‎05-29-2012
My Device: see later
My Carrier: see later

Re: QNETWORKACCESSMANAGER avoid caching