Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does Google Cloud Storage not send correct cache headers?

I have some images in Google Cloud Storage that I want to cache through the standard browser cache. So, in file object metadata field I wrote:

Cache-control : public, max-age=300, no-transform.

But when I get the image by generated URL the cache header reads:

cache-control: no-cache, no-store, max-age=0, must-revalidate.

Why does it happen and how can I fix it?

Headers from browser screenshot

Metadata form in Google Cloud Storage screenshot

like image 716
Konstantin Pershin Avatar asked Jan 17 '26 06:01

Konstantin Pershin


1 Answers

Only objects that are public can be cached as also stated in the documentation:

Cache-Control only applies to objects with a public-read ACL. Non-public data are not cacheable.

You are able to set the Cache-Control metadata even if the object is not public, but it will have no effect.

like image 133
TasosZG Avatar answered Jan 20 '26 18:01

TasosZG



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!