Issue setting Cache-Control header #1087
Copy link
Copy link
Closed
Labels
api: storageIssues related to the Cloud Storage API.Issues related to the Cloud Storage API.type: questionRequest for information or clarification. Not an issue.Request for information or clarification. Not an issue.
Description
Activity
Thanks for reporting this. I'll play with it and let you know if I can find a solution.
- addedapi: storageIssues related to the Cloud Storage API.Issues related to the Cloud Storage API.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
on Jan 26, 2016 Alright, give this a shot:
bucket.upload(source, { destination: dest, gzip: true, metadata: { - 'Vary': 'Accept-Encoding', - 'Cache-Control': 'public, max-age=14400' + cacheControl: 'public, max-age=14400' } }, done)The
varyheader is defaulted.I'm going to send a PR that will make the connection between
options.metadataand the upstream Storage API's resource definition outlined here: https://cloud.google.com/storage/docs/json_api/v1/objects/insert#request_properties_JSONReacted by Mohammad kazemzadeh- addedtype: questionRequest for information or clarification. Not an issue.Request for information or clarification. Not an issue.and removedtype: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
on Jan 26, 2016 Doh, I knew it had to be something silly I was missing. That link to the doc clears up a lot, thanks @stephenplusplus. Worked like a charm once I switched it to
cacheControl. Thanks for the quick response too, much appreciated.No problem. It's our fault for the unclear docs, so thank you for bringing it to our attention!
- added a commit that references this issue
on Feb 5, 2026 - added a commit that references this issue
on Feb 17, 2026 - added a commit that references this issue
on Feb 24, 2026 - added a commit that references this issue
on Mar 11, 2026
Metadata
Metadata
Assignees
Labels
api: storageIssues related to the Cloud Storage API.Issues related to the Cloud Storage API.type: questionRequest for information or clarification. Not an issue.Request for information or clarification. Not an issue.
I've tried quite a few ways of setting the
Cache-Controlmetadata and am unable to do so in a way that is reflected in the object response'sCache-Controlheader. I feel like I've got to be doing something wrong, as this is probably one of the more common headers to set for objects.When I try to set it on the file's
metadataduring upload, it never seems to get set.curl --headcall for the file:I seem to get back the default
Cache-Controlvalue here, and when viewing the file in the Google Cloud UI I see:I then tried calling
file.setMetadata()after the upload:... and I get the following:
Notice the same default value for
Cache-Control, but the appropriate value forx-goog-meta-Cache-Control.In the UI:

I've tried in a bucket with default object permissions as readable by public, and with setting the actual acl on the file during upload as readable by public, but see the same results. Any help would be greatly appreciated.