QNetworkCacheMetaData Class | Qt Network 6.8.3
Description: The QNetworkCacheMetaData class provides cache information.

- Qt 6.8
- Qt Network
- C++ Classes
- QNetworkCacheMetaData
- Qt 6.8.3 Reference Documentation

# QNetworkCacheMetaData Class

The QNetworkCacheMetaData class provides cache information. More...

Header: | `#include <QNetworkCacheMetaData>`
CMake: | `find_package(Qt6 REQUIRED COMPONENTS Network)` `target_link_libraries(mytarget PRIVATE Qt6::Network)`
qmake: | `QT += network`

- List of all members, including inherited members
- QNetworkCacheMetaData is part of Implicitly Shared Classes.

## Public Types

| AttributesMap
| RawHeader
| RawHeaderList

## Public Functions

| QNetworkCacheMetaData()
| QNetworkCacheMetaData(const QNetworkCacheMetaData &other)
| ~QNetworkCacheMetaData()
QNetworkCacheMetaData::AttributesMap | attributes() const
QDateTime | expirationDate() const
`(since 6.8)` QHttpHeaders | headers() const
bool | isValid() const
QDateTime | lastModified() const
QNetworkCacheMetaData::RawHeaderList | rawHeaders() const
bool | saveToDisk() const
void | setAttributes(const QNetworkCacheMetaData::AttributesMap &attributes)
void | setExpirationDate(const QDateTime &dateTime)
`(since 6.8)` void | setHeaders(const QHttpHeaders &headers)
void | setLastModified(const QDateTime &dateTime)
void | setRawHeaders(const QNetworkCacheMetaData::RawHeaderList &list)
void | setSaveToDisk(bool allow)
void | setUrl(const QUrl &url)
void | swap(QNetworkCacheMetaData &other)
QUrl | url() const
bool | operator!=(const QNetworkCacheMetaData &other) const
QNetworkCacheMetaData & | operator=(const QNetworkCacheMetaData &other)
bool | operator==(const QNetworkCacheMetaData &other) const

## Related Non-Members

QDataStream & | operator<<(QDataStream &out, const QNetworkCacheMetaData &metaData)
QDataStream & | operator>>(QDataStream &in, QNetworkCacheMetaData &metaData)

## Detailed Description

QNetworkCacheMetaData provides information about a cache file including the url, when it was last modified, when the cache file was created, headers for file and if the file should be saved onto a disk.

See also QAbstractNetworkCache.

## Member Type Documentation

### QNetworkCacheMetaData::AttributesMap

Synonym for QHash<QNetworkRequest::Attribute, QVariant>

### QNetworkCacheMetaData::RawHeader

Synonym for QPair<QByteArray, QByteArray>

### QNetworkCacheMetaData::RawHeaderList

Synonym for QList<RawHeader>

## Member Function Documentation

### QNetworkCacheMetaData::QNetworkCacheMetaData()

Constructs an invalid network cache meta data.

See also isValid().

### QNetworkCacheMetaData::QNetworkCacheMetaData(const QNetworkCacheMetaData &other)

Constructs a copy of the other QNetworkCacheMetaData.

### `[noexcept]` QNetworkCacheMetaData::~QNetworkCacheMetaData()

Destroys the network cache meta data.

### QNetworkCacheMetaData::AttributesMap QNetworkCacheMetaData::attributes() const

Returns all the attributes stored with this cache item.

See also setAttributes() and QNetworkRequest::Attribute.

### QDateTime QNetworkCacheMetaData::expirationDate() const

Returns the date and time when the meta data expires.

See also setExpirationDate().

### `[since 6.8]` QHttpHeaders QNetworkCacheMetaData::headers() const

Returns headers in form of QHttpHeaders that are set in this meta data.

This function was introduced in Qt 6.8.

See also setHeaders().

### bool QNetworkCacheMetaData::isValid() const

Returns `true` if this network cache meta data has attributes that have been set otherwise false.

### QDateTime QNetworkCacheMetaData::lastModified() const

Returns the date and time when the meta data was last modified.

See also setLastModified().

### QNetworkCacheMetaData::RawHeaderList QNetworkCacheMetaData::rawHeaders() const

Returns a list of all raw headers that are set in this meta data. The list is in the same order that the headers were set.

See also setRawHeaders() and headers().

### bool QNetworkCacheMetaData::saveToDisk() const

Returns is this cache should be allowed to be stored on disk.

Some cache implementations can keep these cache items in memory for performance reasons, but for security reasons they should not be written to disk.

Specifically with http, documents with Cache-control set to no-store or any https document that doesn't have "Cache-control: public" set will set the saveToDisk to false.

See also setSaveToDisk().

### void QNetworkCacheMetaData::setAttributes(const QNetworkCacheMetaData::AttributesMap &attributes)

Sets all attributes of this cache item to be the map attributes.

See also attributes() and QNetworkRequest::setAttribute().

### void QNetworkCacheMetaData::setExpirationDate(const QDateTime &dateTime)

Sets the date and time when the meta data expires to dateTime.

See also expirationDate().

### `[since 6.8]` void QNetworkCacheMetaData::setHeaders(const QHttpHeaders &headers)

Sets the headers of this network cache meta data to headers.

This function was introduced in Qt 6.8.

See also headers().

### void QNetworkCacheMetaData::setLastModified(const QDateTime &dateTime)

Sets the date and time when the meta data was last modified to dateTime.

See also lastModified().

### void QNetworkCacheMetaData::setRawHeaders(const QNetworkCacheMetaData::RawHeaderList &list)

Sets the raw headers to list.

See also rawHeaders() and setHeaders().

### void QNetworkCacheMetaData::setSaveToDisk(bool allow)

Sets whether this network cache meta data and associated content should be allowed to be stored on disk to allow.

See also saveToDisk().

### void QNetworkCacheMetaData::setUrl(const QUrl &url)

Sets the URL this network cache meta data to be url.

The password and fragment are removed from the url.

See also url().

### `[noexcept]` void QNetworkCacheMetaData::swap(QNetworkCacheMetaData &other)

Swaps this metadata instance with other. This operation is very fast and never fails.

### QUrl QNetworkCacheMetaData::url() const

Returns the URL this network cache meta data is referring to.

See also setUrl().

### bool QNetworkCacheMetaData::operator!=(const QNetworkCacheMetaData &other) const

Returns `true` if this meta data is not equal to the other meta data; otherwise returns `false`.

See also operator==().

### QNetworkCacheMetaData &QNetworkCacheMetaData::operator=(const QNetworkCacheMetaData &other)

Makes a copy of the other QNetworkCacheMetaData and returns a reference to the copy.

### bool QNetworkCacheMetaData::operator==(const QNetworkCacheMetaData &other) const

Returns `true` if this meta data is equal to the other meta data; otherwise returns `false`.

See also operator!=().

## Related Non-Members

### QDataStream &operator<<(QDataStream &out, const QNetworkCacheMetaData &metaData)

Writes metaData to the out stream.

See also Serializing Qt Data Types.

### QDataStream &operator>>(QDataStream &in, QNetworkCacheMetaData &metaData)

Reads a QNetworkCacheMetaData from the stream in into metaData.

See also Serializing Qt Data Types.