# Caching and cache breaking

When caching is enabled (cacheEnabled configuration setting set to true) transformed images are cached for the duration of the cacheDuration configuration setting. If an image file is replaced, the existing transforms will be deleted. If a file is moved, the transforms will also be regenerated, since Imager will not find the transforms in the new location.

TIP

By default, transforms are not removed automatically when you move or delete a file. This is intentional to avoid images not being available to cached content, that may not be immediately updated when deleting an asset. If you want to transforms to be automatically deleted, you can set the removeTransformsOnAssetFileops config setting to true.

It's possible to manually remove the generated transforms by clearing the "Transforms cache" from the Imager X utility (Utilities > Imager X). You can also select the images you want to clear in the Assets element list, and choose "Clear Imager transforms" from the element action dropdown menu.

When transforming a remote image, the image will be downloaded and cached for the duration of the cacheDurationRemoteFiles configuration setting by default. You can disable caching of remote images by setting the cacheRemoteFiles config setting to false. This will deteriate performance somewhat, since external images has to be downloaded every time a transform is needed.

You can manually remove the cached images by clearing the "Runtime cache" from the Imager X utility (Utilities > Imager X).

# Can I safely clear my cache then?

"That depends", as they say. 😬

In most cases, clearing out the "Runtime cache" should not have an immediate impact on performance. As long as the transforms persist, any external images or temporary images created, will not be needed anymore.

Clearing the "Transforms cache" on the other hand, will most likely have significant impact on performance and should probably be avoided, at least in production environments.

WARNING

This also is the case even if you use external storages to host your transforms. The files in your imagerSystemPath acts as the cache, Imager will not check if a file exists on an external storage before recreating a transform.