Google cloud storage public object cached on the server side

google-cloud-storagehttp-headers

I have a Google bucket with read permission for allUsers, but it's not configured as a website (and no archiving). I experience an object caching even when I send requests with no-cache control:

gsutil cp test gs://mybucket
# test has default meta Cache-Control: public, max-age=3600
wget -S --no-cache http://storage.googleapis.com/mybucket/test
# OK saved as test
gsutil rm gs://mybucket/test
wget -S --no-cache http://storage.googleapis.com/mybucket/test
# Saved as test.1, why?

I have run the wget --no-cache after the object removal several times. It has sometimes returned the cached test file, sometimes properly HTTP 404. I have run the the commands from a Google Compute Engine Ubuntu server, with no cache configured. I've got the same results from a few machines outside of Google Cloud.

IMO the server has to return HTTP 404 always. Is there a bug in Google Cloud infrastructure?

Note: when I set the object meta Cache-Control:no-cache it works as expected. But I think the server should never return the cached content for the wget --no-cache even when it has the default meta Cache-Control:no-cache

Best Answer

You are correct. Google Cloud Storage currently ignores anonymous client requests to skip the cache.

You can get around this by explicitly setting a different cache-control policy on the object, by requesting a specific generation of an object, or by making authorized requests.

Related Topic