在Google云端存储分区上设置缓存控制 [英] Set Cache-Control on Google Cloud Storage bucket

查看:157
本文介绍了在Google云端存储分区上设置缓存控制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个公共映像经常更新并希望禁用默认缓存持续时间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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆