Subrequests metrics
Hi there,
I wrote a workers to cache request from my graphql endpoint. I mostly following the example here https://blog.cloudflare.com/introducing-the-workers-cache-api-giving-you-control-over-how-your-content-is-cached
As a result I correctly get cached request from the Cloudflare Cache API with status "cf-cache-status: HIT".
However, if I go to the analytics dashboard to "Workers (per zone) > Subrequests > Cached requests" it says 0. "Total requests" is correctly populated with the request I made.
I'm looking at the documentation here https://developers.cloudflare.com/workers/observability/metrics-and-analytics/#subrequests and the way I'm doing it should be correct.
Any pointers on why it's not showing any requests cached?
5 Replies
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
I’m calling cache.match to see if the request is already cached. If not cached, I’m calling fetch
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:
Request n°1:
Request n°2:
okay, now I get it, thanks for the patience
is there a place in the dashboard where I can see the hit ratio analytics for the cache.match from the worker?
I guess with the "Cache Analytics" on the Pro plan minimum?
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?awkwardly Cache Analytics actually filter out those requests in the dashboards they show you, but having Pro would give you access to the dataset which you could then use, just kind of messy
there's a request source just for worker cache api
the dashboards Cache Analytics filter only for eyeball requests/requests directly from users
I see, or I can use the following graphql query:
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