Skip to content

Find Cloudflare cache hit rate for image requests

Background

We (Memory team) are working on the Dynamic Image Resizing epic (gitlab-org&3822), and to make the right decisions on the implementation we need to understand how many image requests are served from the CDN directly vs how many image requests still hit the Rails.

Which data do we need

How many requests for images having one of those URIs:

  • *.jpg?width=*
  • *.png?width=*
  • *.jpeg?width=*
  1. were served from the CDN cache
  2. were served from the app (not from the CDN cache)
    ... for the last ~7 days

If it is possible to understand from logs that we responded with cf-cache-status: HIT header (or something similar which clearly indicates the cache), it is great, as we will get both numbers.
If not, then I will compare the number of responses from Cloudflare with what I see in Kibana (we could take last ~5 days, knowing that we store 7 days in Kibana)


Note from @igorwwwwwwwwwwwwwwwwwwww :

according to https://developers.cloudflare.com/logs/log-fields, the logs have a CacheCacheStatus which should allow getting you those numbers