Best way to get uncached requests to page?

Hi all! I’m the developer of a cloud file sharing and storage platform. I am adding a feature that requires my backend to know how many times certain files have been requested/downloaded. Ideally, this would be performant, since this check will have to run on every request.

I am using Cloudflare caching heavily with a long TTL, meaning my normal solution of incrementing a field in my DB on every request isn’t viable since requests won’t reach my backend server. I need this caching both for speed and to reduce load.

What is the best or most idiomatic way to get the total number of requests to a certain page? Ideally, the data would end up in my database or somewhere that can be accessed performantly, and not be an approximation. My two initial ideas are something involving Workers (never used them before) or using the Cloudflare API. I’m not sure if either is viable.

Thanks in advance!

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.