<!--
{
  "availability" : [
    "iOS: 2.0.0 -",
    "iPadOS: 2.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.2.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/CachedURLResponse/init(response:data:userInfo:storagePolicy:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSCachedURLResponse(im)initWithResponse:data:userInfo:storagePolicy:"
  },
  "title" : "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.

```
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

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

## Discussion

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)