Skip to content

Instantly share code, notes, and snippets.

@mjhassan
Created September 3, 2019 06:06
Show Gist options
  • Select an option

  • Save mjhassan/42d2b156fd3a910563c1512849ddc8fa to your computer and use it in GitHub Desktop.

Select an option

Save mjhassan/42d2b156fd3a910563c1512849ddc8fa to your computer and use it in GitHub Desktop.
URLCache.shared = {
let cacheDirectory = (NSSearchPathForDirectoriesInDomains(.cachesDirectory, .userDomainMask, true)[0] as String).appendingFormat("/\(Bundle.main.bundleIdentifier ?? "cache")/" )
return URLCache(memoryCapacity: /*your_desired_memory_cache_size*/,
diskCapacity: /*your_desired_disk_cache_size*/,
diskPath: cacheDirectory)
}()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment