---
title: "startCachingImages(for:targetSize:contentMode:options:)"
framework: photos
role: symbol
role_heading: Instance Method
path: "photos/phcachingimagemanager/startcachingimages(for:targetsize:contentmode:options:)"
---

# startCachingImages(for:targetSize:contentMode:options:)

Prepares image representations of the specified assets for later use.

## Declaration

```swift
func startCachingImages(for assets: [PHAsset], targetSize: CGSize, contentMode: PHImageContentMode, options: PHImageRequestOptions?)
```

## Parameters

- `assets`: An array of doc://com.apple.photokit/documentation/Photos/PHAsset objects for which to prepare image representations.
- `targetSize`: The size of the images to be prepared.
- `contentMode`: An option for how to fit the images to the aspect ratio of the requested size. For details, see doc://com.apple.photokit/documentation/Photos/PHImageContentMode.
- `options`: Options specifying how Photos should handle the request, format the requested images, and notify your app of progress or errors. For details, see doc://com.apple.photokit/documentation/Photos/PHImageRequestOptions.

## Discussion

Discussion When you call this method, Photos begins to fetch image data and generates thumbnail images on a background thread. At any time afterward, you can use the requestImage(for:targetSize:contentMode:options:resultHandler:) method to request individual images from the cache. If Photos has finished preparing a requested image, that method provides the image immediately. Photos caches images with the exact target size, content mode, and options you specify in this method. If you later request an image with, for example, a different target size than you passed when calling this method, Photos cannot make use of the cache and so it must fetch or generate a new image.

## See Also

### Preparing Images

- [stopCachingImages(for:targetSize:contentMode:options:)](photos/phcachingimagemanager/stopcachingimages(for:targetsize:contentmode:options:).md)
- [stopCachingImagesForAllAssets()](photos/phcachingimagemanager/stopcachingimagesforallassets().md)
