<!--
{
  "availability" : [
    "iOS: 13.0.0 -",
    "iPadOS: 13.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.15.0 -",
    "tvOS: 13.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 6.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/URLCache/init(memoryCapacity:diskCapacity:directory:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "s:So10NSURLCacheC10FoundationE14memoryCapacity04diskD09directoryABSi_SiAC3URLVSgtcfc"
  },
  "title" : "init(memoryCapacity:diskCapacity:directory:)"
}
-->

# init(memoryCapacity:diskCapacity:directory:)

Creates a URL cache object with the specified memory and disk capacities, in the specified directory.

```
convenience init(memoryCapacity: Int, diskCapacity: Int, directory: URL? = nil)
```

## Parameters

`memoryCapacity`

The memory capacity of the cache, in bytes.

`diskCapacity`

The disk capacity of the cache, in bytes.

`directory`

The path to an on-disk directory, where the system stores the on-disk cache. If `directory` is `nil`, the cache uses a default directory.

## Discussion

A disk cache measured in the tens of megabytes is acceptable in most cases.

---

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)