---
title: "init(response:data:userInfo:storagePolicy:)"
framework: foundation
role: symbol
role_heading: Initializer
path: "foundation/cachedurlresponse/init(response:data:userinfo:storagepolicy:)"
---

# init(response:data:userInfo:storagePolicy:)

Creates a cached URL response with a given server response, data, user-info dictionary, and storage policy.

## Declaration

```swift
init(response: URLResponse, data: Data, userInfo: [AnyHashable : Any]? = nil, storagePolicy: URLCache.StoragePolicy)
```

## Parameters

- `response`: The response to cache.
- `data`: The data to cache.
- `userInfo`: An optional dictionary of user information. May be nil.
- `storagePolicy`: The storage policy for the cached response.

## Return Value

Return Value A cached URL response object, containing the response and data.

## See Also

### Creating a cached URL response

- [init(response:data:)](foundation/cachedurlresponse/init(response:data:).md)
