All Collections
FAQs
How long are images and other files cached in ImageKit?
How long are images and other files cached in ImageKit?
Rahul Nanwani avatar
Written by Rahul Nanwani
Updated over a week ago

There are two ways in which you can use ImageKit. You can either store your files in ImageKit's media library or you can attach your storage or web server with ImageKit and deliver the files present there via ImageKit.

If you use ImageKit's media library to store images and files

  1. The original copies of the images and files are stored in the media library permanently.

  2. The transformed and the optimized copies, that get generated when you request them via URL, are usually stored permanently. This is done to improve performance for repeat requests on these images. However, ImageKit might change this practice for specific accounts or all accounts, if and when necessary.

  3. Each image URL is cached on the CDN and other caches in the ImageKit infrastructure for a maximum of 30 days. This is done for a faster delivery of images across the globe.

Note: You are not charged for the storage generated by the original, transformed and optimized copies of the files as long as you stick to the fair usage of storage policy.

If you use your own storage or server with ImageKit

  1. The original copies of the images are present in your own storage or server and ImageKit has nothing to do with how long the images stay there.

  2. The transformed and optimized copies, that get generated when you request them via URL, are stored permanently. This not only improves performance for repeat requests but also ensures that the number of requests made to your storage or server is small. However, ImageKit might change this practice for specific accounts or all accounts, if and when necessary.

  3. Each image URL is cached on the CDN and other caches in the ImageKit infrastructure for a maximum of 30 days. This is done for a faster delivery of images across the globe.

Note: You are not charged for the storage generated by the transformed and optimized copies of the files.

Can I change the cache time of the files?

Yes, you can modify the cache time of your files. However, this can be done only for the files being delivered from your storage or server attached to ImageKit and not for the files stored in the ImageKit media library. You also need to use a custom domain name with ImageKit to be able to customize the cache control time.

ImageKit provides an option of "Origin-based cache control". This allows you to cache on the basis of the cache control headers being passed from the origin attached to ImageKit. So, if your origin (storage or server), sends a cache control header that gets the file to cache for 1 hour, ImageKit will respect that cache control header in all its caches and the CDN. Also, in such cases, ImageKit does not store the transformed and optimized versions of the files at all. This is done to minimize the number of places where the file gets cached which ensures that the cache control set by your origin is obeyed perfectly at all times.

To use this feature, please create a support request from the dashboard, indicating the origin for which you would like to enable origin-based cache control.

My images and files are not cached for 30 days on the CDN?

ImageKit caches your images and files on the CDN for a maximum of 30 days. However, given how CDNs operate, if one of your files is requested only a few times during a day, it may be removed from the cache to make space for other files that are being requested more frequently. This is the nature of all CDNs that exist.

Having said that, even if your file does not get cached on the CDN, ImageKit does store the optimized and transformed images in its systems. So, a request that is not served from the CDN cache, would still get served from our internal caches and storages to ensure a fast delivery to your users.

If you have any feedback or queries, please write to us on support@imagekit.io.

Did this answer your question?