Enumeration Case

NSURLRequestUseProtocolCachePolicy

Use the caching logic defined in the protocol implementation, if any, for a particular URL load request.

Declaration

NSURLRequestUseProtocolCachePolicy = 0

Discussion

This is the default policy for URL load requests.

HTTP Cacheing Behavior

For the HTTP and HTTPS protocols, NSURLRequestUseProtocolCachePolicy performs the following behavior:

  1. If a cached response does not exist for the request, the URL loading system fetches the data from the originating source.

  2. Otherwise, if the cached response does not indicate that it must be revalidated every time, and if the cached response is not stale (past its expiration date), the URL loading system returns the cached response.

  3. If the cached response is stale or requires revalidation, the URL loading system makes a HEAD request to the originating source to see if the resource has changed. If so, the URL loading system fetches the data from the originating source. Otherwise, it returns the cached response.

This behavior is illustrated in Figure 1.

Figure 1

NSURLRequestUseProtocolCachePolicy decision tree for HTTP and HTTPS

Flow chart starting with “need to determine whether to return a cached response”, and then considering various factors to determine whether to return a cached response or to fetch it anew.

See Also

Policies

NSURLRequestReloadIgnoringLocalCacheData

The URL load should be loaded only from the originating source.

NSURLRequestReloadIgnoringLocalAndRemoteCacheData

Ignore local cache data, and instruct proxies and other intermediates to disregard their caches so far as the protocol allows.

NSURLRequestReturnCacheDataElseLoad

Use existing cache data, regardless or age or expiration date, loading from originating source only if there is no cached data.

NSURLRequestReturnCacheDataDontLoad

Use existing cache data, regardless or age or expiration date, and fail if no cached data is available.

NSURLRequestReloadRevalidatingCacheData

Use cache data if it can be validated by the origin source; otherwise, load from the origin.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software