<!--
{
  "availability" : [
    "iOS: 8.0.0 -",
    "iPadOS: 8.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.10.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/URLCache/removeCachedResponse(for:)-1zwp6",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSURLCache(im)removeCachedResponseForDataTask:"
  },
  "title" : "removeCachedResponse(for:)"
}
-->

# removeCachedResponse(for:)

Removes the cached URL response for a specified data task.

```
func removeCachedResponse(for dataTask: URLSessionDataTask)
```

## Parameters

`dataTask`

A task whose URL request’s corresponding cached URL response should be removed. If there is no corresponding cached URL response, no action is taken.

---

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)