Skip to content

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

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'
     });
});

Activity

  1. stephenplusplus commented on Mar 14, 2017

    @stephenplusplus
    Contributor

    Would you mind asking this over on the StackOverflow tag? http://stackoverflow.com/questions/tagged/google-cloud-platform+google-cloud-storage

    GCS team members monitor those tags and are usually pretty timely in helping. I think you'll get a better answer than I can give. If you do post, please link us so we can follow along. If there are any changes needed from our side, we will definitely fix it here. Thanks!

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

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