GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Issue setting Cache-Control header · Issue #1087 · googleapis/google-cloud-node

Issue setting Cache-Control header #1087

New issue
Copy link
New issue
Copy link
Closed
Closed
Issue setting Cache-Control header#1087
Copy link
Assignees
selfcontained
Labels
api: storageIssues related to the Cloud Storage API.type: questionRequest for information or clarification. Not an issue.

Description

@selfcontained
selfcontained
opened on Jan 25, 2016
Issue body actions

I've tried quite a few ways of setting the Cache-Control metadata and am unable to do so in a way that is reflected in the object response's Cache-Control header. 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 metadata during upload, it never seems to get set.

bucket.upload(source, {
  destination: dest,
  gzip: true,
  metadata: {
    'Vary': 'Accept-Encoding',
    'Cache-Control': 'public, max-age=14400'
  }
}, done)

curl --head call for the file:

HTTP/1.1 200 OK
X-GUploader-UploadID: AEnB2UrsdtueM7WljXcrRXU3NwRCqDJ-kL6_wPze_OeEzPUsa05eC2hzAUDsY6S5mpyPRr79hRD_UlPJ0rqaBVs9WsMDMopMVg
Expires: Tue, 26 Jan 2016 00:18:34 GMT
Date: Mon, 25 Jan 2016 23:18:34 GMT
Cache-Control: public, max-age=3600
Last-Modified: Mon, 25 Jan 2016 23:18:29 GMT
ETag: W/"9072e88dbe39c375e51263697684c9ef"
x-goog-generation: 1453763909213000
x-goog-metageneration: 1
x-goog-stored-content-encoding: gzip
x-goog-stored-content-length: 56043
Content-Type: application/javascript; charset=utf-8
x-goog-hash: crc32c=d9f3Pw==
x-goog-hash: md5=kHLojb45w3XlEmNpdoTJ7w==
x-goog-storage-class: STANDARD
Vary: Accept-Encoding
Server: UploadServer
Alternate-Protocol: 443:quic,p=1
Alt-Svc: quic=":443"; ma=604800; v="30,29,28,27,26,25"
Transfer-Encoding: chunked

I seem to get back the default Cache-Control value here, and when viewing the file in the Google Cloud UI I see:

image

I then tried calling file.setMetadata() after the upload:

file.setMetadata({
  metadata: {
    'Cache-Control': 'public, max-age=57600'
  }
}, done)

... and I get the following:

Notice the same default value for Cache-Control, but the appropriate value for x-goog-meta-Cache-Control.

HTTP/1.1 200 OK
X-GUploader-UploadID: AEnB2Ur-Sisk_qHR767OwpO-hQJwEFyGlkIJ6Tx-XAe0pCCUXWeeu-k38wpImLQnlWvr82p74AjzHO_iuvv-6kWAsP63E_UpCg
Expires: Tue, 26 Jan 2016 00:23:20 GMT
Date: Mon, 25 Jan 2016 23:23:20 GMT
Cache-Control: public, max-age=3600
Last-Modified: Mon, 25 Jan 2016 23:22:40 GMT
ETag: W/"9072e88dbe39c375e51263697684c9ef"
x-goog-generation: 1453764160154000
x-goog-metageneration: 2
x-goog-stored-content-encoding: gzip
x-goog-stored-content-length: 56043
x-goog-meta-Cache-Control: public, max-age=57600
Content-Type: application/javascript; charset=utf-8
x-goog-hash: crc32c=d9f3Pw==
x-goog-hash: md5=kHLojb45w3XlEmNpdoTJ7w==
x-goog-storage-class: STANDARD
Vary: Accept-Encoding
Server: UploadServer
Alternate-Protocol: 443:quic,p=1
Alt-Svc: quic=":443"; ma=604800; v="30,29,28,27,26,25"
Transfer-Encoding: chunked

In the UI:
image

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.

Activity

  1. stephenplusplus commented on Jan 26, 2016

    @stephenplusplus
    stephenplusplus
    on Jan 26, 2016
    Contributor
    More actions

    Thanks for reporting this. I'll play with it and let you know if I can find a solution.

  2. stephenplusplus
    added
    api: storageIssues related to the Cloud Storage API.
    type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.
    on Jan 26, 2016
  3. stephenplusplus commented on Jan 26, 2016

    @stephenplusplus
    stephenplusplus
    on Jan 26, 2016
    Contributor
    More actions

    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 vary header is defaulted.

    I'm going to send a PR that will make the connection between options.metadata and the upstream Storage API's resource definition outlined here: https://cloud.google.com/storage/docs/json_api/v1/objects/insert#request_properties_JSON

    Reacted by Mohammad kazemzadeh
  4. stephenplusplus
    added
    type: questionRequest for information or clarification. Not an issue.
    and removed
    type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.
    on Jan 26, 2016
  5. selfcontained commented on Jan 26, 2016

    @selfcontained
    selfcontained
    on Jan 26, 2016
    Author
    More actions

    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.

  6. selfcontained
    closed this as completedon Jan 26, 2016
  7. stephenplusplus commented on Jan 26, 2016

    @stephenplusplus
    stephenplusplus
    on Jan 26, 2016
    Contributor
    More actions

    No problem. It's our fault for the unclear docs, so thank you for bringing it to our attention!

  8. JustinBeckwith
    assigned
    selfcontained
    on Feb 1, 2021
  9. miguelvelezsa
    added 2 commits that reference this issue on Jul 23, 2025

    fix: do not throw error on empty LRO response (#1087)

    6b39247

    chore: release 2.24.2 (#1088)

    07810ec
  10. sofisl
    added a commit that references this issue on Feb 5, 2026

    chore: store nodejs build artifacts in placer (#1087)

    47d892c
  11. sofisl
    added a commit that references this issue on Feb 17, 2026

    chore: store nodejs build artifacts in placer (#1087)

    8144cb8
  12. sofisl
    added a commit that references this issue on Feb 24, 2026

    feat!: Drop Node 8 support (#1006)

    2500a99
  13. GautamSharda
    added a commit that references this issue on Mar 11, 2026

    fix: make request batching work again (#1087)

    523f0a7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @selfcontained
    selfcontained

Labels

api: storageIssues related to the Cloud Storage API.type: questionRequest for information or clarification. Not an issue.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.