Type Property

ephemeral

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

Declaration

class var ephemeral: URLSessionConfiguration { get }

Return Value

A configuration object optimized for transferring data to and from your app’s memory.

Discussion

An ephemeral session configuration object is similar to a default session configuration object except that the corresponding session object does not store caches, credential stores, or any session-related data to disk. Instead, session-related data is stored in RAM. The only time an ephemeral session writes data to disk is when you tell it to write the contents of a URL to a file.

The main advantage to using ephemeral sessions is privacy. By not writing potentially sensitive data to disk, you make it less likely that the data will be intercepted and used later. For this reason, ephemeral sessions are ideal for private browsing modes in web browsers and other similar situations.

Because an ephemeral session does not write cached data to disk, the size of the cache is limited by available RAM. This limitation means that previously fetched resources are less likely to be in the cache (and are guaranteed to not be there if the user quits and relaunches your app). This behavior may reduce perceived performance, depending on your app.

When your app invalidates the session, all ephemeral session data is purged automatically. Additionally, in iOS, the in-memory cache is not purged automatically when your app is suspended but may be purged when your app is terminated or when the system experiences memory pressure.

See Also

Creating a Session Configuration Object

class var `default`: URLSessionConfiguration

Returns a newly created default session configuration object.

class func background(withIdentifier: String)

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