0
votes

I made a bucket on Google Cloud Storage and filled it with images for a project and I want to enable browser caching for them. As far as I know, this just means I need to disable bucket policy only, add "allUsers" as a 'Storage Object Viewer' role and add the 'cache-control: public, max-age=x' header to the object metadata for each image. I've done those steps, but every time I make a request for the image, either from my app or just the browser, I get back the response header 'cache-control: no-cache, no-store, max-age=0, must-revalidate'. Is there a step I'm missing here?

As you can see, the images are public:

Public images

And the metadata is set like this:

Metadata

And yet, the response is always this:

enter image description here

2

2 Answers

1
votes

Was able to solve this with the help of one of my friends. Even though the bucket was publicly accessible, I had to set the ACL permissions on each object to give all users reader permissions (grant the user entity 'allUsers', 'reader' access. Once I set that I got my caching working as expected.

0
votes

I've worked through the same issue. You are using the wrong host name, use https://storage.googleapis.com/{{bucket}}....