CachedAsyncImage is AsyncImage, but with cache capabilities.
Usage
CachedAsyncImage has the exact same API and behavior as AsyncImage, so you just have to change this:
AsyncImage(url: logoURL)
to this:
CachedAsyncImage(url: logoURL)
In addition to AsyncImage initializers, you have the possibilities to specify the cache you want to use (by default URLCache.shared is used), and to use URLRequest instead of URL:
SwiftUI CachedAsyncImage 🗃️
CachedAsyncImageisAsyncImage, but with cache capabilities.Usage
CachedAsyncImagehas the exact same API and behavior asAsyncImage, so you just have to change this:to this:
In addition to
AsyncImageinitializers, you have the possibilities to specify the cache you want to use (by defaultURLCache.sharedis used), and to useURLRequestinstead ofURL:Remember when setting the cache the response (in this case our image) must be no larger than about 5% of the disk cache (See this discussion).
Installation
https://github.com/lorenzofiamingo/swiftui-cached-async-image) and click Next.Other projects
SwiftUI AsyncButton 🖲️
SwiftUI MapItemPicker 🗺️
SwiftUI PhotosPicker 🌇
SwiftUI VerticalTabView 🔝
SwiftUI SharedObject 🍱