Skip to content
Storage

Cache Metrics

Cache hits can be determined via the log_attributes['response.headers.cf_cache_status'] key in the logs. 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:

select
log_attributes['request.path'] as path,
log_attributes['request.search'] as search,
count() as count
from logs
where source = 'edge_logs'
and startsWith(log_attributes['request.path'], '/storage/v1/object')
and log_attributes['request.method'] = 'GET'
and log_attributes['response.headers.cf_cache_status'] in ('MISS', 'NONE/UNKNOWN', 'EXPIRED', 'BYPASS', 'DYNAMIC')
group by path, search
order by count desc
limit 50;

Try out this query in the SQL Editor.

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

select
toStartOfHour(timestamp) as timestamp,
countIf(log_attributes['response.headers.cf_cache_status'] in ('HIT', 'STALE', 'REVALIDATED', 'UPDATING')) / count() as ratio
from logs
where source = 'edge_logs'
and startsWith(log_attributes['request.path'], '/storage/v1/object')
and log_attributes['request.method'] = 'GET'
group by timestamp
order by timestamp desc
limit 100;

Try out this query in the SQL Editor.