[英]How to invalidate cache on Google Cloud Bucket in php code
i'm using Google Cloud Bucket as CDN.我正在使用 Google Cloud Bucket 作为 CDN。 When i upload an image to CDN, i set
cache-control: public, max-age=31536000
(365 days).当我将图像上传到 CDN 时,我设置了
cache-control: public, max-age=31536000
(365 天)。 Then i want to replace that image by another one, but i don't know how to invalidate the old cache.然后我想用另一个替换那个图像,但我不知道如何使旧缓存无效。 I'm using Google Cloud PHP Client SDK https://github.com/googleapis/google-cloud-php .
我正在使用谷歌云 PHP 客户端 SDK https://github.com/googleapis/google-cloud-php 。
I tried to delete the old image and upload a new image but it didn't work.我尝试删除旧图像并上传新图像,但没有成功。 I still get the old version.
我仍然得到旧版本。
Does anyone know about this?有人知道吗?
Neither the PHP API client nor the JSON API expose this admin method PHP API 客户端和 JSON ZDB974238714CA8DE634A7CE1D083A14F 均未公开此管理方法
... therefore one could only wrap the gcloud
command with PHP-CLI: ...因此只能使用 PHP-CLI 包装
gcloud
命令:
function clear_cdn_cache($urlmap_name) {
$cmd = 'gcloud compute url-maps invalidate-cdn-cache '.$urlmap_name.' --path "/*"';
$stdout = shell_exec($cmd);
echo "<pre>$stdout</pre>";
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.