A powerful image loading and caching system

Caching

Two cache layers including fast LRU memory cache, and native HTTP cache or custom aggressive LRU disk cache.

Integrations

Nuke is a pipeline with injectable dependencies. Alamofire, Gifu, WebP, FLAnimatedImage plugins available.

Progressive JPEG, WebP

Enable progressive decoding with a single line of code. Nuke has support for both progressive JPEG (built-in) and WebP (built by the community).

Preheating Images

Automatically prefetch images ahead of time using special low-priority requests. Can be used with both Preheat and native table and collection view prefetching APIs.

Resumable Downloads

If the data task fails with an error or gets canceled and the image was partially loaded, the next load will resume where it was left off (HTTP range requests).

Animated Images (GIFs)

You can use either FLAnimatedImage or Gifu plugin to load and display animated GIFs with smooth scrolling performance and low memory footprint.

Both of the plugins are extremely small (10-30 lines of code). You can either install them using a package manager or simply copy the code in your project.

Performance

Performance is one of the key differentiating factors for Nuke. There are three key components of its performance:

  • Main-Thread Performance. The framework is tuned to do very little work on the main thread. It's at least 2.7x faster than other frameworks.
  • Robustness Under Stress. Nuke is completely asynchronous, it executes work on a dedicated queues with a limited maximum number of concurrent tasks. Under stress image pipeline will rate limit the requests to prevent trashing underlying systems.
  • Memory Usage. Nuke uses LRU (least recently used) replacement algorithm. It limits memory usage to ~20% of available RAM. As a good citizen, it evicts images on memory warnings and removes most of them when the app enters background.

Nuke also collects detailed performance metrics during the execution of each task.

Main-Thread Performance

Nuke is tuned to do very little work on the main thread which helps achieve buttery smooth scrolling performance in table and collection views.

RxNuke

RxNuke adds RxSwift extensions for Nuke and enables many common use cases:

  • Going from low to high resolution
  • Loading the first available image
  • Showing stale image while validating it
  • Load multiple images, display all at once
  • Auto retry requests

Here's an example of how easy it is to load go flow log to high resolution:

let pipeline = ImagePipeline.shared
Observable.concat(pipeline.loadImage(with: lowResUrl).orEmpty,
                  pipeline.loadImage(with: highResUtl).orEmpty)
    .subscribe(onNext: { imageView.image = $0.image })
    .disposed(by: disposeBag)