12.7 · Image loading pipelines: download, decode, downsample, cache
Images are the largest part of most apps’ traffic and memory. A good pipeline treats them as four separate costs: bytes, decoding, pixels in memory and repeated requests.
Mental model. A file’s size on disk means little. What matters is how many pixels you hold decoded, and how often you fetch or decode the same one.
The pipeline
Each stage and what it costs.
- How do you design an image loading pipeline: decoding, downsampling, caching and de-duplication?
Think of the pipeline as stages, each with its own cost and cache. 1) Fetch the bytes with URLSession: honour HTTP caching, cancel when the cell leaves the…
More in Networking
- 12.1 · Sessions, configurations, tasks, delegates and background transfers
- 12.2 · HTTP versions, TLS, App Transport Security and certificate pinning
- 12.3 · Pagination, caching and conditional requests, and authentication refresh
- 12.4 · WebSockets, multipart and large transfers, and network path monitoring
- 12.5 · Retries, backoff, idempotency and cancellation
- 12.6 · REST, GraphQL and gRPC, and building a client platform
- 12.8 · Building URLs, reading headers, classifying errors and timeouts
- 12.9 · Single-flight token refresh, streaming lines, multipart bodies and request signing
- 12.10 · Network.framework, background sessions, delegates versus async, diagnosing and measuring