Cloudflare R2 files are not cached when requested via custom domain

I connected a public R2 bucket through my domain. Now this domain has Proxied status, but all GET requests to files on this domain get to R2 and counted as Class B operations, although logically they should be distributed from the cache. Who can clarify how it should be?

How are the cache-control headers on the responses?

You might need to enable the caching on those resources.

I do not use any headers. How to enable caching?

You do, for sure, they will be set automatically, but I’m not sure how they are set by R2.

Either give me a link to some resource or post the response/request headers.

I also have this issue with R2 not caching images. I’ve set up page rules to cache everything and my CORS settings are below.

[
{
“AllowedOrigins”: [
"
],
“AllowedMethods”: [
“GET”,
“POST”,
“HEAD”,
“PUT”,
“DELETE”
],
“AllowedHeaders”: [
"

],
“ExposeHeaders”: [
“*”,
“Expires”,
“Content-Type”,
“Cache-Control”
],
“MaxAgeSeconds”: 31536000
}
]

Not all file types are cached by default. Common image and font files are, but somewhat surprisingly, HTML files aren’t.

You should find all you need to know in the R2 Public Buckets docs:

https://developers.cloudflare.com/r2/buckets/public-buckets/

Of particular interest will probably be the “Enabling cache for all file types” note in the Custom Domains section, which links to a page that includes a list of the file types which are cached by default