Why is my "Cache hit statistics" showing a lot of Miss traffic?

Since ImageKit is a CDN, a lot of content should get served from the CDN itself. But in my account, a lot of content, over 30% is getting missed from the CDN. What could be the reason for this and how to fix it?

There could be multiple reasons for this.

  1. If your URLs are changing frequently, then cache utilization will be low. For example, if you are adding some sort of versioning parameter in your URLs by adding some query parameter that changes after some time, then the cache hit would be low.
  2. If you have timestamp-based expiry in your signed URLs, then because the URLs cannot be cached beyond their expiry time, the cache hit would be low.
  3. If you use custom origin-based cache control in ImageKit, and the origin responds with a low cache control header, then also the cache hit would be low.
  4. If your traffic pattern involves infrequent access to content i.e. there are a few requests to that asset and are spread over the entire month and these requests come from different locations, then the CDN could be removing your content from cache as it is not “popular” or frequently requested. This is a standard behavior of all CDNs. Only content that is accessed by end users frequently, stays in the cache.