0
votes

Hope every is doing great. I am upload files using google storage utility to file with gzip compression enable

gsutil -h 'Content-Type:application/json; charset=utf-8' -h 'Cache-Control:Cache-Control:public,max-age=3600' cp -z filejson gs://{bucket_name}/{id}/{id}/file.json 

Issue is by default when I use this command to upload files, it's set file metadata cache control to no-transform. When I down this file on client (like browser).I can read the content of the file. Is there any way I can allow tranform to object metadata. So it will work fine on clients.

1

1 Answers

0
votes

From the Documentation:

This can be achieved using gsutil setmeta. The gsutil setmeta command allows you to set or remove the metadata on one or more objects.

By default, publicly readable objects are served with a Cache-Control header allowing such objects to be cached for 3600 seconds. For more details about this default behavior see the CACHE-CONTROL section of gsutil help metadata. As the example shows:

 gsutil -h "Content-Type:text/html" \
       -h "Cache-Control:public, max-age=3600" cp -r images \
       gs://bucket/images

On the other hand, if you need to ensure that updates become visible immediately, you should set a Cache-Control header of "Cache-Control:private, max-age=0, no-transform" on such objects. You can do this with the example command:

gsutil setmeta -h "Content-Type:text/html" \
  -h "Cache-Control:private, max-age=0, no-transform" gs://bucket/*.html

You can learn more about Cache-Control here