{"id":15667418,"url":"https://github.com/0xwdg/cachedasyncimage","last_synced_at":"2025-05-06T19:46:56.990Z","repository":{"id":246089483,"uuid":"820068366","full_name":"0xWDG/CachedAsyncImage","owner":"0xWDG","description":"CachedAsyncImage is a Swift Package for asynchronously loading images from the web and caching them.","archived":false,"fork":false,"pushed_at":"2025-02-20T20:15:49.000Z","size":854,"stargazers_count":11,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-05-01T17:04:01.242Z","etag":null,"topics":["0xwdg","async","asyncimage","cached","cachedasyncimage","hacktoberfest","images","spm","swiftui"],"latest_commit_sha":null,"homepage":"https://0xwdg.github.io/CachedAsyncImage/","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/0xWDG.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"0xWDG"}},"created_at":"2024-06-25T18:24:47.000Z","updated_at":"2025-04-07T01:35:44.000Z","dependencies_parsed_at":"2024-06-25T20:20:59.610Z","dependency_job_id":"3f1ee3d1-d68a-4904-bff4-aeffef321214","html_url":"https://github.com/0xWDG/CachedAsyncImage","commit_stats":{"total_commits":8,"total_committers":1,"mean_commits":8.0,"dds":0.0,"last_synced_commit":"d1e184e3a48af8de889557989bad49eca9f4a514"},"previous_names":["0xwdg/cachedasyncimage"],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/0xWDG%2FCachedAsyncImage","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/0xWDG%2FCachedAsyncImage/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/0xWDG%2FCachedAsyncImage/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/0xWDG%2FCachedAsyncImage/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/0xWDG","download_url":"https://codeload.github.com/0xWDG/CachedAsyncImage/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252757408,"owners_count":21799671,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["0xwdg","async","asyncimage","cached","cachedasyncimage","hacktoberfest","images","spm","swiftui"],"created_at":"2024-10-03T14:03:22.617Z","updated_at":"2025-05-06T19:46:56.941Z","avatar_url":"https://github.com/0xWDG.png","language":"Swift","funding_links":["https://github.com/sponsors/0xWDG"],"categories":[],"sub_categories":[],"readme":"# CachedAsyncImage\n\nCachedAsyncImage is a Swift Package for asynchronously loading images from the web and caching them.\n\n[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2F0xWDG%2FCachedAsyncImage%2Fbadge%3Ftype%3Dplatforms)](https://swiftpackageindex.com/0xWDG/CachedAsyncImage)\n[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2F0xWDG%2FCachedAsyncImage%2Fbadge%3Ftype%3Dswift-versions)](https://swiftpackageindex.com/0xWDG/CachedAsyncImage)\n[![Swift Package Manager](https://img.shields.io/badge/SPM-compatible-brightgreen.svg)](https://swift.org/package-manager)\n![License](https://img.shields.io/github/license/0xWDG/CachedAsyncImage)\n\n## Requirements\n\n- Swift 5.9+ (Xcode 15+)\n- iOS 13+, macOS 10.15+\n\n## Installation (Pakage.swift)\n\n```swift\ndependencies: [\n    .package(url: \"https://github.com/0xWDG/CachedAsyncImage.git\", branch: \"main\"),\n],\ntargets: [\n    .target(name: \"MyTarget\", dependencies: [\n        .product(name: \"CachedAsyncImage\", package: \"CachedAsyncImage\"),\n    ]),\n]\n```\n\n## Installation (Xcode)\n\n1. In Xcode, open your project and navigate to **File** → **Swift Packages** → **Add Package Dependency...**\n2. Paste the repository URL (`https://github.com/0xWDG/CachedAsyncImage`) and click **Next**.\n3. Click **Finish**.\n\n## Usage\n\n`CachedAsyncImage` has the exact same API and behavior as `AsyncImage`, so you just have to change this:\n\n```swift\nAsyncImage(url: logoURL)\n```\n\nto this:\n\n```swift\nCachedAsyncImage(url: logoURL)\n```\n\nexample:\n\n```swift\nimport SwiftUI\nimport CachedAsyncImage\n\nstruct ContentView: View {\n    var body: some View {\n        VStack {\n            CachedAsyncImage(\n                url: URL(\n                    string: \"https://wesleydegroot.nl/assets/avatar/avatar.webp\"\n                )\n            ) { image in\n                image\n                    .resizable()\n                    .frame(width: 250, height: 250)\n            } placeholder: {\n                ProgressView()\n            }\n        }\n        .padding()\n    }\n}\n```\n\nIn 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`:\n\n```swift\nCachedAsyncImage(urlRequest: logoURLRequest, urlCache: .imageCache)\n```\n\n```swift\n// URLCache+imageCache.swift\n\nextension URLCache {\n\n    static let imageCache = URLCache(memoryCapacity: 512_000_000, diskCapacity: 10_000_000_000)\n}\n```\n\nRemember 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](https://developer.apple.com/documentation/foundation/nsurlsessiondatadelegate/1411612-urlsession#discussion)).\n\n## Contact\n\n🦋 [@0xWDG](https://bsky.app/profile/0xWDG.bsky.social)\n🐘 [mastodon.social/@0xWDG](https://mastodon.social/@0xWDG)\n🐦 [@0xWDG](https://x.com/0xWDG)\n🧵 [@0xWDG](https://www.threads.net/@0xWDG)\n🌐 [wesleydegroot.nl](https://wesleydegroot.nl)\n🤖 [Discord](https://discordapp.com/users/918438083861573692)\n\nInterested learning more about Swift? [Check out my blog](https://wesleydegroot.nl/blog/).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F0xwdg%2Fcachedasyncimage","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F0xwdg%2Fcachedasyncimage","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F0xwdg%2Fcachedasyncimage/lists"}