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
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With