Storage

Cache Metrics


Cache hits can be determined via the metadata.response.headers.cf_cache_status key in our Logs Explorer. Any value that corresponds to either HIT, STALE, REVALIDATED, or UPDATING is categorized as a cache hit. The following example query will show the top cache misses from the edge_logs:


_17
select
_17
r.path as path,
_17
r.search as search,
_17
count(id) as count
_17
from
_17
edge_logs as f
_17
cross join unnest(f.metadata) as m
_17
cross join unnest(m.request) as r
_17
cross join unnest(m.response) as res
_17
cross join unnest(res.headers) as h
_17
where
_17
starts_with(r.path, '/storage/v1/object')
_17
and r.method = 'GET'
_17
and h.cf_cache_status in ('MISS', 'NONE/UNKNOWN', 'EXPIRED', 'BYPASS', 'DYNAMIC')
_17
group by path, search
_17
order by count desc
_17
limit 50;

Try out this query in the Logs Explorer.

Your cache hit ratio over time can then be determined using the following query:


_12
select
_12
timestamp_trunc(timestamp, hour) as timestamp,
_12
countif(h.cf_cache_status in ('HIT', 'STALE', 'REVALIDATED', 'UPDATING')) / count(f.id) as ratio
_12
from
_12
edge_logs as f
_12
cross join unnest(f.metadata) as m
_12
cross join unnest(m.request) as r
_12
cross join unnest(m.response) as res
_12
cross join unnest(res.headers) as h
_12
where starts_with(r.path, '/storage/v1/object') and r.method = 'GET'
_12
group by timestamp
_12
order by timestamp desc;

Try out this query in the Logs Explorer.