在Google云端存储分区上设置缓存控制 [英] Set Cache-Control on Google Cloud Storage bucket
问题描述
我有一个公共映像经常更新并希望禁用默认缓存持续时间3600的存储桶(例如Cache-Control:private,max-age = 0,no-transform)
在使用PHP上传文件时,Cache-Control可以设置为文件吗?
有没有一种方法可以为存储桶中所有将来的文件设置默认的Cache-Control(就像使用ACL,所有文件都是公共的)?
现在我只能使用gsutil将其设置为Cache-Control,并且只能用于存储当前文件。
您可以在上传对象时设置Cache-Control - 我建议您使用gsutil -D查看它生成的请求的示例,然后将其转换为PHP:
gsutil -D -h Cache-Control:Cache-Control:private,max-age = 0,no-transform\
cp file gs:// your-bucket / file
没有办法设置默认的Cache-Control for桶。
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.
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.
这篇关于在Google云端存储分区上设置缓存控制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!