Can I use Cloudflare Workers and Cache API to serve non-HTML content?

Can I use Cloudflare Workers in conjunction with Cache API to serve images only?

I want to API responses in R2 and Cache API. And serve from Cache API first and if not found, server from R2 and populate Cache API.

Isn’t this use case prohibited?

Disclaimer that I’m not a lawyer or speaking officially, but my understanding is this:

R2 itself is governed by https://www.cloudflare.com/supplemental-terms/ - you’re allowed to store videos, images, basically anything you like in R2 and serve it directly to customers as you wish.

The Cache API however is governed by https://www.cloudflare.com/terms/#28-limitation-on-serving-non-html-content, which includes a limitation on serving disproportional amounts of non-HTML content. What that number looks like is going to vary on your use case, size, and amount of requests, etc. though.

3 Likes

Hi,

I’m in the same case, wondering if I can cache a modest number (20 ish) of small videos (10 mb in general) and being compliant with the TOS. Could a staff member clarify if thats ok ?

Kind regards

Thanks for the response, but I am partially agree with you.

How do you know that Cache API is governed by regular terms. It is not stated directly.

And in addition to that, you can serve any content from Workers according to supplemental terms, it is not stated whether it could use or could not use Cache API.

Can we mention some official to clarify these questions in terms and state directly the usage of Cache API?

Can you share where you read this? I believe that’s from an older version of the terms.

Hi, I can’t share links on the forum. But this is the quote from the supplemental terms:

The Cloudflare Developer Platform consists of the following Services: (i) Cloudflare Workers, a Service that permits developers to deploy and run encapsulated versions of their proprietary software source code (each a “Workers Script”) on Cloudflare’s edge servers; (ii) Cloudflare Pages, a JAMstack platform for frontend developers to collaborate and deploy websites; and (iii) Workers KV, Durable Objects, and R2, storage offerings used to serve HTML and non-HTML content.

So, if I use Cloudflare Workers I can non-HTML content, but there is no mention of the cache. Does it matter at all?

That’s a specific list of products that can serve non-HTML content, yes. My understanding once again is that everything else, including the cache, is governed by https://www.cloudflare.com/terms/#28-limitation-on-serving-non-html-content.

I’m not sure you’ll get any official answer, but maybe someone else can provide more insight.

Yes, but I want to serve the content through Cloudflare Workers and only store in the cache. Does it make sense?

Hi, @ngao! Maybe you can clarify?