Skip to content
Storage

缓存指标

可以通过我们日志浏览器中的 metadata.response.headers.cf_cache_status 键来确定缓存命中。任何对应 HITSTALEREVALIDATEDUPDATING 的值都被归类为缓存命中。以下示例查询将显示来自 edge_logs 的最常见缓存未命中情况:

🌐 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:

1
select
2
r.path as path,
3
r.search as search,
4
count(id) as count
5
from
6
edge_logs as f
7
cross join unnest(f.metadata) as m
8
cross join unnest(m.request) as r
9
cross join unnest(m.response) as res
10
cross join unnest(res.headers) as h
11
where
12
starts_with(r.path, '/storage/v1/object')
13
and r.method = 'GET'
14
and h.cf_cache_status in ('MISS', 'NONE/UNKNOWN', 'EXPIRED', 'BYPASS', 'DYNAMIC')
15
group by path, search
16
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:

1
select
2
timestamp_trunc(timestamp, hour) as timestamp,
3
countif(h.cf_cache_status in ('HIT', 'STALE', 'REVALIDATED', 'UPDATING')) / count(f.id) as ratio
4
from
5
edge_logs as f
6
cross join unnest(f.metadata) as m
7
cross join unnest(m.request) as r
8
cross join unnest(m.response) as res
9
cross join unnest(res.headers) as h
10
where starts_with(r.path, '/storage/v1/object') and r.method = 'GET'
11
group by timestamp
12
order by timestamp desc;

在日志探索器中试试 这个查询

🌐 Try out this query in the Logs Explorer.