image-loading

Cache and deduplicate image loading in SwiftUI apps with CachedAsyncImage.

27|5|Updated Apr 18, 2026
One-click install
npx skills add https://github.com/bocan/bocan-music --skill image-loading-bocan
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: image-loading
Source: https://github.com/bocan/bocan-music/tree/main/.claude/skills/generators/image-loading
Command: npx skills add https://github.com/bocan/bocan-music --skill image-loading-bocan

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

The default SwiftUI AsyncImage view lacks built-in caching, request deduplication, and image processing capabilities, leading to redundant network downloads, excessive memory usage, and poor scrolling performance in apps that display repeated images like avatars, thumbnails, or grid content.

Core Features & Use Cases

  • Full caching stack: Combines NSCache memory cache, LRU disk cache, and actor-based request deduplication to eliminate redundant downloads and reduce memory footprint by up to 1500x for large images.
  • Drop-in SwiftUI view: Includes a CachedAsyncImage view that works as a direct replacement for the built-in AsyncImage with no changes to existing view code.
  • Optional image processing: Supports resizing and thumbnail generation to optimize images for their display size, and prefetching for smooth scrolling in lists and grids.
  • Use case: Ideal for SwiftUI apps with user avatar lists, media galleries, or product grids that need offline support, fast scrolling, and low memory overhead.

Quick Start

Use the image-loading skill to generate a complete cached image loading pipeline with a drop-in CachedAsyncImage view for your SwiftUI project.

Frequently Asked Questions about image-loading

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
Why does SwiftUI AsyncImage download the same image repeatedly in my list views?

SwiftUI AsyncImage lacks built-in caching and request deduplication, causing redundant network downloads for repeated images like avatars or thumbnails. Implementing an LRU disk cache and memory cache eliminates duplicate requests and significantly reduces network traffic.

How do I add memory and disk caching to image loading in SwiftUI?

To add image caching in SwiftUI, implement a pipeline combining NSCache for memory caching and an LRU disk cache. This full caching stack prevents redundant downloads and reduces memory overhead by up to 1500x for large images in scrolling lists.

What is the best way to prevent duplicate image download requests in iOS 16+ apps?

The best way to prevent duplicate image downloads is using actor-based request deduplication. This mechanism ensures only one network request fires per unique URL, even when multiple SwiftUI views simultaneously request the same image resource.

Can I replace the default AsyncImage view with a cached version without changing my SwiftUI code?

Yes, you can use a drop-in CachedAsyncImage SwiftUI view as a direct replacement for the built-in AsyncImage. It requires no changes to existing view code and immediately provides offline support, memory caching, and smoother scrolling.

Does SwiftUI AsyncImage support image processing and resizing for thumbnails?

The default AsyncImage does not support image processing, but a cached image loading pipeline can include optional resizing and thumbnail generation. This optimizes images for their display size and enables prefetching for smooth scrolling in media galleries.

How do I reduce high memory usage when displaying a grid of images in a SwiftUI app?

To reduce high memory usage in SwiftUI image grids, replace the default AsyncImage with a cached pipeline featuring NSCache memory management and optional image resizing. This approach prevents excessive memory consumption and ensures smooth scrolling performance.