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:

1
select
2
log_attributes['request.path'] as path,
3
log_attributes['request.search'] as search,
4
count() as count
5
from logs
6
where source = 'edge_logs'
7
and startsWith(log_attributes['request.path'], '/storage/v1/object')
8
and log_attributes['request.method'] = 'GET'
9
and log_attributes['response.headers.cf_cache_status'] in ('MISS', 'NONE/UNKNOWN', 'EXPIRED', 'BYPASS', 'DYNAMIC')
10
group by path, search
11
order by count desc
12
limit 50;

Try out this query in the SQL Editor.

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

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

Try out this query in the SQL Editor.