jeremy
jeremy
Explore posts from servers
CDCloudflare Developers
Created by jeremy on 4/24/2024 in #workers-help
Subrequests metrics
I see, or I can use the following graphql query:
{
viewer {
zones {
workersZoneInvocationsAdaptiveGroups(filter: {httpResponseStatus:200, date_gt:"2024-04-20"}, limit:10) {
dimensions {
httpResponseStatus
status
}
sum {
requests
subrequests
}
}
}
}
}
{
viewer {
zones {
workersZoneInvocationsAdaptiveGroups(filter: {httpResponseStatus:200, date_gt:"2024-04-20"}, limit:10) {
dimensions {
httpResponseStatus
status
}
sum {
requests
subrequests
}
}
}
}
}
and do subrequest/requests? would that be the same result? I'm planning to pay for the workers add-on, but not the whole pro plan, which I wouldn't really need
12 replies
CDCloudflare Developers
Created by jeremy on 4/24/2024 in #workers-help
Subrequests metrics
alright, I see, thanks Would "Cache Analytics" from Pro plan would give me this data without doing the math myself, or it's just something not available in the dashboard?
12 replies
CDCloudflare Developers
Created by jeremy on 4/24/2024 in #workers-help
Subrequests metrics
I guess with the "Cache Analytics" on the Pro plan minimum?
12 replies
CDCloudflare Developers
Created by jeremy on 4/24/2024 in #workers-help
Subrequests metrics
is there a place in the dashboard where I can see the hit ratio analytics for the cache.match from the worker?
12 replies
CDCloudflare Developers
Created by jeremy on 4/24/2024 in #workers-help
Subrequests metrics
okay, now I get it, thanks for the patience
12 replies
CDCloudflare Developers
Created by jeremy on 4/24/2024 in #workers-help
Subrequests metrics
sorry to be a wall, that's why I am asking for help. I'm not understanding this properly. Here is a walkthrough: - api endpoint: api.domain.com - requests are made to api.domain.com - workers is trigger on route api.domain.com Code snippet:
response = await cache.match(cacheKey)

if (!response) {
response = await fetch(request.url, newRequest)
event.waitUntil(cache.put(cacheKey, response.clone()))
}
response = await cache.match(cacheKey)

if (!response) {
response = await fetch(request.url, newRequest)
event.waitUntil(cache.put(cacheKey, response.clone()))
}
Request n°1:
response = await cache.match(cacheKey)
// response = undefined
// then we are calling fetch to origin, and caching response with cache.put
// cf-cache-status: DYNAMIC
response = await cache.match(cacheKey)
// response = undefined
// then we are calling fetch to origin, and caching response with cache.put
// cf-cache-status: DYNAMIC
Request n°2:
response = await cache.match(cacheKey)
// response = something here
// we return the response because it exists in the cache
// cf-cache-status: HIT
response = await cache.match(cacheKey)
// response = something here
// we return the response because it exists in the cache
// cf-cache-status: HIT
12 replies
CDCloudflare Developers
Created by jeremy on 4/24/2024 in #workers-help
Subrequests metrics
I’m calling cache.match to see if the request is already cached. If not cached, I’m calling fetch
12 replies
CDCloudflare Developers
Created by jeremy on 4/24/2024 in #workers-help
Subrequests metrics
Are you sure? Reading at the following documentation, I'm not understanding it this way: - "Subrequests are requests triggered by calling fetch from within a Worker." - "Cached: The number of cached responses returned." When I'm doing a request to my endpoint, the worker kicks in, and it goes through the Worker fetch logic. If cache.match exists, it returns the cached request, if not, it calls origin (with fetch) and cache the response
12 replies