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, if that makes 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 like:
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'
});
});
When I visit the image at the public url (https://storage.googleapis.com/my-bucket-name.appspot.com/storageBucketName/imageName.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/storageBucketName/imageName.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!
via jemise111
No comments:
Post a Comment