Image Caching in Swift

Episode 1

Cancelling Image Requests


Most applications display images in some way, shape, or form. Those images are often fetched from a remote server, introducing a number of interesting challenges. Performing a request to a remote server takes time and it requires resources. It is therefore important to consider solutions to minimize the number of requests an application makes.

Episode 2 Plus

Caching Images in Memory


We added the ability to cancel image requests in the previous episode. This and the next episode focus on caching images. We start simple by caching images in memory.

Episode 3 Plus

Caching Images on Disk


In this episode, we continue to improve the solution we implemented in this series by caching images on disk. Caching images on disk has a number of benefits. It reduces the number of requests the application makes and it improves the performance of the application. The user experiences the application as fast and snappy.

Episode 4 Plus

Asynchronously Reading Data from Disk


The previous episodes have illustrated that caching images can result in significant performance improvements. In the previous episode, I stressed the importance of writing cached images to disk on a background thread to prevent the image service from blocking the main thread.