When you build a downloader that runs on other people's APIs, retries feel like free insurance. A request fails, so you try again. What could go wrong? On my own site, quite a lot, and it took me one expensive afternoon to learn the difference between a retry that helps and a retry that just burns quota.
The site I run is ramrom.io , a free video downloader for TikTok, Instagram, Facebook and YouTube. It sits on shared hosting, plain PHP, and talks to a handful of RapidAPI providers. Most of those providers charge per request, not per success. That single fact changes how you should think about retrying.
So I drew a line, and it is simple: I retry only when I can prove the request never reached the provider.
A connection that fails before the request leaves my server is safe to retry. A DNS failure, a connect timeout, a curl error with no HTTP status at all β in those cases nothing was charged, because nothing arrived.β¦