0

When setting the cache-control metadata key via the gsutils command:

gsutil -m setmeta -h "Cache-Control:public, max-age=14400" 'gs://my-bucket/style.css'

I verify that the metadata is updated correctly using another gsutils command:

gsutil stat 'gs://my-bucket/style.css'

However, when accessing this object via curl --head the value is not update

content-type: text/css
age: 232
cache-control: public,max-age=3600

I am expecting for the max-age of the cache-control property to be set to the value specified in the gsutil command which is 14400.

  • 1
    Andre - did you wait 3600 seconds after updating the metadata before checking? If you attempted the `curl` command sooner than that you could be seeing the cached oldervalue. – Mike Schwartz Nov 29 '22 at 22:00
  • Yes I waited over an hour and don't see the updated value in the response headers. This is some of the metadata I see when doing `gsutil stat`: **Storage class: MULTI_REGIONAL Cache-Control: public, max-age=14400 Content-Length: 62207** – Andre Barrientos Nov 30 '22 at 01:04
  • That `gsutil stat` command is sending an HTTP `GET`, while the`curl` command is sending an HTTP `HEAD`. I wonder whether there is a proxy in your path that incorrectly handles HTTP `HEAD`. Are you running the `curl` command from behind a corporate firewall or via a proxy? – Mike Schwartz Nov 30 '22 at 15:36
  • I was, I just tried it with the VPN off and even on another laptop and still see the same result unfortunately. – Andre Barrientos Nov 30 '22 at 16:33
  • Hello @MikeSchwartz , when doing the `curl --HEAD` I am requesting the object via a CDN url; whereas for the `gsutil` I am using the path to the object. Does there need to be some configuration on the CDN to be able to use the object metadata for caching? – Andre Barrientos Dec 14 '22 at 16:02
  • Unfortunately I have not worked with the CDN. I found this page: https://cloud.google.com/cdn/docs/using-ttl-overrides which makes me wonder if you have a TTL override configured. – Mike Schwartz Dec 15 '22 at 13:36
  • I was not using the correct cache-mode on the bucket, solution was in updating the cache-mode to USE_ORIGIN_HEADERS. Thank you! – Andre Barrientos Jan 11 '23 at 16:50

1 Answers1

0

I was not using the correct cache-mode on the bucket, solution was in updating the cache-mode to USE_ORIGIN_HEADERS. Thank you!