I have a bucket with public images that are frequently updated and would like to disable the default cache duration of 3600. (E.g. "Cache-Control:private, max-age=0, no-transform")
Can the Cache-Control be set on a file while uploading it with PHP?
Is there a way to set the default Cache-Control for all future files in the bucket (like with ACL that all files are public)?
Right now I can only set it Cache-Control with gsutil and only for files currently on storage.
Using IAM permissions with ACLs Cloud Storage offers two systems for granting users access your buckets and objects: IAM and Access Control Lists (ACLs). These systems act in parallel - in order for a user to access a Cloud Storage resource, only one of the systems needs to grant that user permission.
gsutil is a Python application that lets you access Cloud Storage from the command line. You can use gsutil to do a wide range of bucket and object management tasks, including: Creating and deleting buckets. Uploading, downloading, and deleting objects.
You can set the Cache-Control while uploading an object - I suggest you use gsutil -D to see an example of the request it generates to do this, and then translate that to PHP:
gsutil -D -h Cache-Control:"Cache-Control:private, max-age=0, no-transform" \
cp file gs://your-bucket/file
There's no way to set a default Cache-Control for the bucket.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With