I have an IPFS server set up to return content such as JSON, GIF images, and MP3 data. Given that this content (GIF, MP3) can be large and sending it from the origin host can be slower than desired - I’m trying to find a way to use Cloudfare in order to cache this data so that it is served faster.
I’m somewhat familiar with “Page Rules” for caching, but I’m confused as to how I might be able to leverage these for my specific use case.
Basically I would love to cache the media at GET - https://myserver.com/ipfs/ABCD123 so that the next time a user requests GET - https://myserver.com/ipfs/ABCD123 , they are served the cached resources - as opposed to putting load on the origin server. With this ABCD123 identifier potentially either being GIF bytes or MP3 bytes
Is this possible? I apologize if I’ve left out any details
set up a Cache Everything rule for your URL path followed by an asterisk. In your case:
PageRule match: https://myserver.com/ipfs/*
PageRule config: Cache Level: Cache Everything Edge TTL: (your available max value)
That should be it. You would be ready to go. Please notice, that as it is against the TOS 2.8 you still can do it, but please keep you traffic and cache small, otherwise you (if exceeded some TB) probably will be informed that you are in violation of ToS 2.8.
Thank you for the detailed response @M4rt1n. I was not aware that this violated ToS 2.8. I will try a different approach but the answer is still helpful
Do not cache. But that again is the problem, you want to cache it. Cloudflare is really awesome in hiding you IP. But if you dont have regular content you better contact the sales team or look out for not having more then some TB cache/traffic, but these numbers are no official numbers, just speaking from what was considered too much somewhen before.