Skip to content

Cache-Control max-age header issues with storage bucket images #2077

@jemise111

Description

@jemise111

Hello! I'm having trouble setting the cache-control max-age header for images in my storage bucket.

The images are actually stored in a firebase storage bucket, I'm not sure if that should make any difference.

I can successfully upload an image receive the file object in the response. I then set the cache-control max-age header for the file to 31536000.

When I visit the image at the public url (https://storage.googleapis.com/my-bucket-name.appspot.com/path/to/image.png) the cache-control max-age header is set to 3600, which is the default.

Oddly enough if I visit the public url over http (http://storage.googleapis.com/my-bucket-name.appspot.com/path/to/image.png) the cache-control max-age header is set to 31536000, as expected.

How can I set this header for the public url available over https? Thanks for any help!

Environment details

  • OS: Mac 10.12.3
  • Node.js version: 6.9.1
  • google-cloud-node version: 0.46.2

Steps to reproduce

const gcloud = require('google-cloud');
const gcs = gcloud.storage({credentials: myCredentials});
const storageBucket = gcs.bucket(myConfig);

storageBucket.upload('path/to/image', {
    public: true,
    destination: storageBucket.file('storageBucketName/imageName.png')
} , (err, file, apiResponse) => {
    file.setMetadata({
        cacheControl: 'public, max-age=31536000'
     });
});

Metadata

Metadata

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