Can we set Cloudflare R2 cache-control max-age?

213 views Asked by At

Can we set the Cache-Control HTTP response header for our Cloudflare R2 buckets & objects? I could not find options in the web UI nor the AWS CLI "s3" and "s3api" commands. I'm now convinced Cloudflare looses money if we can use Cache-Control headers to limit the number of requests to their servers .

2

There are 2 answers

0
anthumchris On BEST ANSWER

The s3api provides the --cache-control option for commands:

0
Richard On

If you use rclone you can use the flag --header-upload to specify a header. For example:

rclone copy --header-upload='Cache-Control: public, max-age=31536000, immutable' app/public/bundle/assets/index-CsRe289b.js r2:static/production/assets/

See https://rclone.org/flags/