Enable cache in an R2 bucket
To enable edge caching for a Cloudflare R2 bucket, make sure your bucket is public and accessible by the Cache. This can be done by creating a Custom Domain. Follow these steps to set up a Custom Domain for your bucket:
- Go to R2 and select your bucket.
- On the bucket page, select Settings.
- Under Public access > Custom Domains, select Connect Domain.
- Enter the domain name you want to connect to and select Continue.
- Review the new record that will be added to the DNS table and select Connect Domain.
This will generate a publicly available CNAME in the format [name].domain.com
.
- Apply access controls to your newly public bucket. Refer to Control cache access with WAF and Snippets for more information.
- Be aware of the cacheable size limits for files.