1

We have a Google Cloud LB setup with an backend storage bucket and CDN enabled, i added the allUsers member with Storage Object Viewer permissions so we can reach the public data with an normal url.

The problem: We always get cache-control: private, max-age=0 header and this only goes away if we add the allUsers to the specific object, is there a way to set it to the whole bucket? Now none of our assets are being cached.

TriPSs
  • 117
  • 1
  • 8

1 Answers1

1

Cache-Control can only be set to public on publicly readable objects. This used to be documented here: https://web.archive.org/web/20180923170014/https://cloud.google.com/storage/docs/gsutil/addlhelp/WorkingWithObjectMetadata

As of 2022, it looks like this is still true, but it is no longer mentioned on the same documentation page.

ValarDohaeris
  • 6,064
  • 5
  • 31
  • 43
Mike Schwartz
  • 11,511
  • 1
  • 33
  • 36
  • I added the `allUsers` to the bucket view permissions so it's a publicly readable object. – TriPSs Jun 19 '18 at 09:12
  • Or do i need to add more permissions to the bucket to make sure the cache-control goes to public? If i update the code that when each file is uploaded with options `"predefinedAcl" => "publicRead",` it works, but it also worked before and then i did not have to add this code as the permissions on the bucket where enough. – TriPSs Jun 19 '18 at 12:00
  • The object's permissions are what matter for Cache-Control. If you set the predefinedAcl on the bucket that determines what default ACL will be set on objects written from then on, so if there are objects that were uploaded before that predefinedAcl was set you'll also need to make those objects publicly readable for Cache-Control to be public. – Mike Schwartz Jun 23 '18 at 16:48