---
title: "init(memoryCapacity:diskCapacity:diskPath:)"
framework: foundation
role: symbol
role_heading: Initializer
path: "foundation/urlcache/init(memorycapacity:diskcapacity:diskpath:)"
---

# init(memoryCapacity:diskCapacity:diskPath:)

Creates a URL cache object with the specified values.

## Declaration

```swift
init(memoryCapacity: Int, diskCapacity: Int, diskPath path: String?)
```

## Parameters

- `memoryCapacity`: The memory capacity of the cache, in bytes.
- `diskCapacity`: The disk capacity of the cache, in bytes.
- `path`: In macOS, path is the location at which to store the on-disk cache. In iOS, path is the name of a subdirectory of the application’s default cache directory in which to store the on-disk cache (the subdirectory is created if it does not exist).

## Return Value

Return Value The initialized cache object.

## Discussion

Discussion The returned cache instance is backed by disk, so you have more leeway when choosing the capacity for this kind of cache. A disk cache measured in the tens of megabytes should be acceptable in most cases.

## See Also

### Related Documentation

- [shared](foundation/urlcache/shared.md)

### Creating a new cache object

- [init(memoryCapacity:diskCapacity:directory:)](foundation/urlcache/init(memorycapacity:diskcapacity:directory:).md)
