There are web attributes (void QWebSettings::setAttribute(WebAttribute attribute, bool on)):
QWebSettings::LocalStorageDatabaseEnabled
QWebSettings::OfflineWebApplicationCacheEnabled
QWebSettings::OfflineStorageDatabaseEnabled
There are also methods:
void QWebSettings::enablePersistentStorage(const QString &path = QString())
void QWebSettings::setMaximumPagesInCache(int pages)
void QWebSettings::setObjectCacheCapacities(int cacheMinDeadCapacity, int cacheMaxDead, int totalCapacity)
void QWebSettings::setOfflineStorageDefaultQuota(qint64 maximumSize)
void QWebSettings::setOfflineStoragePath(const QString &path)
void QWebSettings::setOfflineWebApplicationCachePath(const QString &path)
void QWebSettings::setOfflineWebApplicationCacheQuota(qint64 maximumSize)
And there is QNetworkDiskCache which can be used with QNetworkAccessManager:
QNetworkDiskCache *diskCache = new QNetworkDiskCache(this);
QString location = QDesktopServices::storageLocation(QDesktopServices::CacheLocation);
diskCache->setCacheDirectory(location);
networkAccessManager->setCache(diskCache);
It has also couple of methods:
void setCacheDirectory(const QString &cacheDir)
void setMaximumCacheSize(qint64 size)
How should I implement caching properly with this confusing API?
When loading pages, there are a number of levels of caching involved, from fastest to slowest:
(3) and (4) are out of your control, (1) is enabled by default, so the only thing you potentially need to do is enable (2).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With