Rockwell Rice
Rockwell Rice

Reputation: 3002

Google Cloud Storage serves up old image when file names are the same

Running into an issue with hosted images in Google Cloud Storage. When an image gets uploaded to a destination and has the same name as a file there it replaces the file, however Google continues to serve up the old image at the URL.

If I go into the bucket I can see the preview of the new image, however, clicking the link will open a window and show the old image.

How do I fix this so it shows the updated image?

Upvotes: 2

Views: 1163

Answers (1)

Rockwell Rice
Rockwell Rice

Reputation: 3002

So I had to set the max-age to 0 when uploading the image.

  const options = {
    expires: Date.now() + 1 * 60 * 1000, // 1 minute,
    fields: { 
      'x-goog-meta-test': 'data',
      'Cache-Control': 'max-age=0', <----------- this is what I needed
     },
  };

Upvotes: 4

Related Questions