0

i'm using Google Cloud Bucket as CDN. When i upload an image to CDN, i set cache-control: public, max-age=31536000 (365 days). 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.

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?

Martin Zeitler
  • 1
  • 19
  • 155
  • 216
Peter
  • 21
  • 1
  • 2

2 Answers2

0

Neither the PHP API client nor the JSON API expose this admin method

... therefore one could only wrap the gcloud command with PHP-CLI:

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>";
}
Martin Zeitler
  • 1
  • 19
  • 155
  • 216
-2

This solution doesn’t use Google Cloud PHP, however if you check out this link, you may find the answers you are looking for.