It’s the case like CDN. The responding time is the most important thing, and i need to decide whether to fetch from IPFS or fetch from source site for a short time.
In that case, I’d just set a lower timeout. Also, if you end up downloading the file from the source site, I’d add it to IPFS (and verify the hash). You can also try racing. That is, ask both IPFS and the website (but maybe give IPFS 75ms to return a response before asking the website). If the website is under heavy load, it can start rejecting requests and you can wait for IPFS to return the file.
Do we have a better way to accomplish it?
Set a lower timeout, that’s the only way to do this. As we make content routing faster and faster (we’re working on it) you’ll be able to lower that timeout more and more.
However, we’ll likely keep our timeouts where they are. In most cases, you want to keep trying until you find something and there’s no way to be completely sure that nobody has the content in question (there’s no way to know if you’ve asked every node in the network).