Benjamin Meyer
Qt
WebKit
Internet
Posted by Benjamin Meyer
 in Qt, WebKit, Internet
 on Monday, August 04, 2008 @ 15:01

The past few weeks I have been hacking on another feature in Qt. Going with the theme of making Qt 4.5 faster I added a cache system to QNetworkAccessManager and provided a simple QNetworkDiskCache that can be used by most applications. Under the hood the new http backend has been enhanced to support all the http rfc cache features you would expect (even behave better than FireFox in one case). Adding a cache system is very important to a lot of our customers.

- Anyone who wants to use rss/atom feeds absolutely must have a cache system in place.
- Anyone who uses QtWebKit has been looking forward to a cache system.
- Any other application that pulls down files off the network such as in XMLPatterns can use the cache to improve performance and reduce network overhead.

To store the cache QDesktopServices::storageLocation has a new enum CacheLocation that can be used to determine a proper cross platform location for where cache files can be stored. The included QNetworkDiskCache is simple and should be good enough for a lot of customers, but for those that want to write a highly optimized one for small devices or to hook into another cache system (such as MSIE’s) the interface QAbstractNetworkCache is provided so you can implement custom cache systems.

For many applications enabling the cache will be as simple as:
QNetworkDiskCache *diskCache = new QNetworkDiskCache(this);
QString location = QDesktopServices::storageLocation(QDesktopServices::CacheLocation);
diskCache->setCacheDirectory(location);
networkAccessManager->setCache(diskCache);

To see it in action you can checkout the demo browser the 4.5 snapshots where I have enabled it.

2 Responses to “Network Cache!”

» Posted by ariya
 on Monday, August 04, 2008 @ 20:14

Yay! Towards a flying Arora!

» Posted by mart
 on Tuesday, August 05, 2008 @ 21:12

Glad someone’s having some success with QNetworkAccessManager…
I spent last night trying to subclass it in Jambi, and use it for a QWebFrame/QWebPage - so far, all I’ve managed to do is kill the JVM a few dozen times :o( One begins to wonder if it’s even possible…

I do like Arora though. :)



© 2008 Nokia Corporation and/or its subsidiaries. Nokia, Qt and their respective logos are trademarks of Nokia Corporation in Finland and/or other countries worldwide.
All other trademarks are property of their respective owners.