google-app-enginegoogle-cloud-storage

Google Cloud Storage - Public object url e super slow updating


I have a bucket with READ permission to allUsers and it's working fine but the public url link https://storage.googleapis.com/example_bucket/example.png takes ages to update: if I change the image in storage for a different one with the same name, the bucket view shows the correct image as well as the not public image url https://storage.cloud.google.com/example_bucket/example.png however the public url shows the old image and it takes a long time to update. Could someone explain if this is normal or if I'm doing something wrong?


Solution

  • You can set the cache-control when you are uploading the object:

    Using gsutil when

    1. Uploading

    gsutil -D -h Cache-Control:"Cache-Control:private, max-age=0, no-transform" cp file gs://BUCKET/file

    1. Editing: gsutil set meta

    gsutil setmeta -h Cache-Control:"Cache-Control:private, max-age=0, no-transform" gs://BUCKET/file

    Or through the console:

    enter image description here

    Currently, there is no way to set a default cache-control for the bucket.

    You might be interested in taking a look into this Viewing / Editing Metadata