Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting default cache-control header for gsutil rsync

Since there is unfortunately no way to set a default cache-control header for a bucket (which there really should be...), is there a way to specify a default cache-control header for the gsutil rsync command? Or barring that, an easy way to programmatically get a list of all the files actually changed during the rsync, that we can pass into the setmeta command?

Since we have quite a few files which change for each deploy, we have to do a setmeta on ** after each deploy, which takes an unreasonable amount of time... but haven't figured out any better way to reliably ensure correct cache-control headers for all files in the cloud storage bucket, since there is no way to set up proper defaults for either the bucket itself or the rsync command. Is there a better way to accomplish this goal? What are we missing?

like image 810
Rylab Avatar asked Jul 19 '16 18:07

Rylab


1 Answers

If you want the same Cache-Control header for all the files you upload, you could use the gsutil -h option to cause the gsutil rsync command to set the Cache-Control headers. Example:

gsutil -m -h "Cache-Control:private, max-age=0, no-transform" rsync -r ./dir gs://my-bucket
like image 99
Mike Schwartz Avatar answered Sep 24 '22 00:09

Mike Schwartz