Feb 24, 2023 • 1 min read
Google Cloud Storage Metadata
Introduction
If you are using a Google Cloud Storage bucket for application development you may want to use this handy tip. When working with data, you can turn off the cache-control option. If you want to test things like temporary JSON or image files, this setting is super useful.
Amend the bucket metadata
Google Cloud Storage provides a number of metadata key/value pairs. One useful setting is the Cache-Control. The default option is to have cache enabled. If you plan to use temporary data, it might be advisable to amend the setting as follows:
| Field | Value |
|---|---|
| Cache-Control | no-store, max-age=0, public |
Effectively this tells Google Cloud Storage to not cache the object.
The benefit of this is, when data is replaced, it will refer to the latest version, rather than using eventual consistency.
-
Set the metadata on existing objects:
NODE_TYPE // bashgcloud storage objects update gs://your-bucket-name/your-object-name --cache-control="no-store, max-age=0, public" -
Alternatively set metadata on upload:
NODE_TYPE // bashgcloud storage cp -r ./my-folder gs://your-bucket-name/ --cache-control="no-store, max-age=0, public"
To learn more about metadata settings: