A configuration object that defines behavior and policies for a URL session.


@interface NSURLSessionConfiguration : NSObject


An NSURLSessionConfiguration object defines the behavior and policies to use when uploading and downloading data using an NSURLSession object. When uploading or downloading data, creating a configuration object is always the first step you must take. You use this object to configure the timeout values, caching policies, connection requirements, and other types of information that you intend to use with your NSURLSession object.

It is important to configure your NSURLSessionConfiguration object appropriately before using it to initialize a session object. Session objects make a copy of the configuration settings you provide and use those settings to configure the session. Once configured, the session object ignores any changes you make to the NSURLSessionConfiguration object. If you need to modify your transfer policies, you must update the session configuration object and use it to create a new NSURLSession object.

For more information about using configuration objects to create sessions, see NSURLSession.

Types of Session Configurations

The behavior and capabilities of a URL session are largely determined by the kind of configuration used to create the session.

The singleton shared session (which has no configuration object) is for basic requests. It’s not as customizable as sessions that you create, but it serves as a good starting point if you have very limited requirements. You access this session by calling the shared class method. See that method’s discussion for more information about its limitations.

Default sessions behave much like the shared session (unless you customize them further), but let you obtain data incrementally using a delegate. You can create a default session configuration by calling the default method on the URLSessionConfiguration class.

Ephemeral sessions are similar to default sessions, but they don’t write caches, cookies, or credentials to disk. You can create an ephemeral session configuration by calling the ephemeral method on the URLSessionConfiguration class.

Background sessions let you perform uploads and downloads of content in the background while your app isn’t running. You can create a background session configuration by calling the backgroundSessionConfiguration(_:) method on the URLSessionConfiguration class.


Creating a Session Configuration Object


A default session configuration object.


A session configuration that uses no persistent storage for caches, cookies, or credentials.


Creates a session configuration object that allows HTTP and HTTPS uploads or downloads to be performed in the background.

Setting General Properties


The background session identifier of the configuration object.


A dictionary of additional headers to send with requests.


The type of network service for all tasks within sessions based on this configuration.


A Boolean value that determines whether connections should be made over a cellular network.


The timeout interval to use when waiting for additional data.


The maximum amount of time that a resource request should be allowed to take.


The identifier for the shared container into which files in background URL sessions should be downloaded.


A Boolean value that indicates whether the session should wait for connectivity to become available, or fail immediately.

Setting Cookie Policies


A policy constant that determines when cookies should be accepted.


A Boolean value that determines whether requests should contain cookies from the cookie store.


The cookie store for storing cookies within this session.


A container that manages the storage of cookies.


A representation of an HTTP cookie.

Setting Security Policies


The maximum TLS protocol version that the client should request when making connections in this session.


The minimum TLS protocol that should be accepted during protocol negotiation.


A credential store that provides credentials for authentication.

Setting Caching Policies


The URL cache for providing cached responses to requests within the session.


A predefined constant that determines when to return a response from the cache.

Supporting Background Transfers


A Boolean value that indicates whether the app should be resumed or launched in the background when transfers finish.


A Boolean value that determines whether background tasks can be scheduled at the discretion of the system for optimal performance.


A Boolean value that indicates whether TCP connections should be kept open when the app moves to the background.

Supporting Custom Protocols


An array of extra protocol subclasses that handle requests in a session.


An abstract class that handles the loading of protocol-specific URL data.

Supporting Multipath TCP

Improving Network Reliability Using Multipath TCP

Use the available radios in iOS devices to improve your app’s network reliability and performance.


A service type that specifies the Multipath TCP connection policy for transmitting data over Wi-Fi and cellular interfaces.


Constants that specify the type of service that Multipath TCP uses.

Setting HTTP Policy and Proxy Properties


The maximum number of simultaneous connections to make to a given host.


A Boolean value that determines whether the session should use HTTP pipelining.


A dictionary containing information about the proxy to use within this session.

Supporting Connectivity Changes


A Boolean value that indicates whether the session should wait for connectivity to become available, or fail immediately.

Deprecated Methods


Returns a session configuration object that allows HTTP and HTTPS uploads or downloads to be performed in the background.



Multipath Entitlement

A Boolean value that indicates whether the app may use Multipath protocols like Multipath TCP to smoothly hand over traffic from one interface to another.


Inherits From

Conforms To

See Also

First Steps

Fetching Website Data into Memory

Receive data directly into memory by creating a data task from a URL session.


An object that coordinates a group of related network data transfer tasks.


A task, like downloading a specific resource, performed in a URL session.