Skip To Content ArcGIS for Developers Sign In Dashboard

NetworkCacheConfiguration Class

(Esri::ArcGISRuntime::NetworkCacheConfiguration)

A singleton class to configure HTTP network caching options. More...

Header: #include <NetworkCacheConfiguration>
Since: Esri::ArcGISRuntime 100.8
Inherits: Object

Public Functions

~NetworkCacheConfiguration()
QString cacheDirectory() const
NetworkCachePolicy cachePolicy() const
qint64 cacheSize() const
void clearCache()
qint64 maximumCacheSize() const
bool networkCachingEnabled() const
void setCacheDirectory(const QString &directory)
void setCachePolicy(NetworkCachePolicy policy)
void setMaximumCacheSize(qint64 maxSize)
void setNetworkCachingEnabled(bool enabled)
  • 31 public functions inherited from QObject

Signals

Additional Inherited Members

  • 1 property inherited from QObject
  • 1 public slot inherited from QObject
  • 1 public variable inherited from QObject
  • 10 static public members inherited from QObject
  • 9 protected functions inherited from QObject
  • 2 protected variables inherited from QObject

Detailed Description

A singleton class to configure HTTP network caching options.

Network requests can be cached locally to improve performance and reduce the number of network requests. Access the singleton instance through RequestConfiguration::globalNetworkCacheConfiguration.

Member Function Documentation

NetworkCacheConfiguration::~NetworkCacheConfiguration()

Destructor.

QString NetworkCacheConfiguration::cacheDirectory() const

Returns the directory to store the cached responses.

The default path is the value returned by QStandardPaths::CacheLocation and depends on the platform:

  • MacOS - "~/Library/Caches/<APPNAME>" or "/Library/Caches/<APPNAME>".
  • Windows - "C -/Users/<USER>/AppData/Local/<APPNAME>/cache".
  • linux - "~/.cache/<APPNAME>"
  • Android - "<APPROOT>/cache" or "<USER>/<APPNAME>/cache"
  • iOS - "<APPROOT>/Library/Caches"

See also setCacheDirectory().

NetworkCachePolicy NetworkCacheConfiguration::cachePolicy() const

Returns the cache behavior for requests.

The default value is NetworkCachePolicy::PreferNetwork.

See also setCachePolicy() and NetworkCachePolicy.

qint64 NetworkCacheConfiguration::cacheSize() const

Returns the current size taken up by the cache.

Returns 0 if the cache is disabled.

void NetworkCacheConfiguration::clearCache()

Clears the cache directory.

qint64 NetworkCacheConfiguration::maximumCacheSize() const

Returns the maximum size for the disk cache in bytes.

The default value is 100 MBs (100,000,000 bytes).

See also setMaximumCacheSize().

bool NetworkCacheConfiguration::networkCachingEnabled() const

Returns whether the network caching is enabled.

This is a global setting and applies to all network requests.

The default value is true.

When set to false, no disk caching will be used. When set to true, network requests will attempt to cache results and use those as possible when the same request is made again.

Network caching can improve the performance of loading network resources.

See also setNetworkCachingEnabled().

[signal] void NetworkCacheConfiguration::networkCachingEnabledChanged()

Signal emitted when the networkCachingEnabled property changes.

void NetworkCacheConfiguration::setCacheDirectory(const QString &directory)

Sets the directory to store the cached responses from directory.

See also cacheDirectory().

void NetworkCacheConfiguration::setCachePolicy(NetworkCachePolicy policy)

Sets the cache behavior for requests to policy.

See also cachePolicy() and NetworkCachePolicy.

void NetworkCacheConfiguration::setMaximumCacheSize(qint64 maxSize)

Sets the maximum size for the disk cache in bytes to maxSize.

See also maximumCacheSize().

void NetworkCacheConfiguration::setNetworkCachingEnabled(bool enabled)

Sets network caching to enabled.

This is a global setting and applies to all network requests.

See also networkCachingEnabled().


Feedback on this topic?