How to check Cloudflare cache status programmatically

Just imagine: your small web app, that allows user to download medium-large ZIP files, due a lucky reddit post, suddenly start to receive huge amount of traffic, and specifically a lot of downloads.

The server is a small tier with a very small bandwith: a peak of downloads after a new file release turn in a DDOS for your webapp.