Caching IPFS media responses


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 - so that the next time a user requests GET - , 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

Thats would violate ToS 2.8

Technically it would go like this:

  1. proxy your domain with Cloudflare
  2. set up a port that allows caching: 80, 443, 8080
  3. set up a Cache Everything rule for your URL path followed by an asterisk. In your case:

PageRule match:*

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.

Have fun.

1 Like

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

Little help, for working around 2.8:

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.

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