Cloud Storage the deleted file still accessible

Viewed 238

I am deleting a JSON file from Cloud Storage. However, this file I deleted is still accessible. I know it sounds silly. When I list the files that exist in cloud storage, this file is not listed. However, I can access this file with the URL.

I'll try to give you an example.

I'm calling the file from cloud storage with Postman:

[
    {
        "_id": "60ad0e33b7161e270d7f9bf2",
        "id": 1,
        "city": "Rotterdam",
        "hours_0_sun": 2.4,
        "daily_0_temp_day": 11.5,
        ....
    },
    {
      ...
    }
]

When I remove the file

const key = `someid-someid.json`;
const bucket = storage.bucket(process.env.GCLOUD_BUCKET_NAME);
const file = bucket.file(key);
const response = await file.delete();

And call the file again:

[
    {
        "_id": "60ad0e33b7161e270d7f9bf2",
        "id": 1,
        "city": "Rotterdam",
        "hours_0_sun": 2.4,
        "daily_0_temp_day": 11.5,
        ....
    },
    {
      ...
    }
]

File's still accessible...

When I try to get the file from storage:

            //Find file
const options = {
   prefix: `someid-someid.json`
};

let files = await storage.bucket(process.env.GCLOUD_BUCKET_NAME).getFiles(options);
console.log(files);

Console:

[[]]

This is driving me mad. Is this normal? How can I delete the file completely?

Note: When I delete the file, I can't see the file from the storage browser too. So file doesn't exist in the storage. But still accessible...

1 Answers

I found the problem thanks to @Kolban he mentioned CDN caches in the comments.

I setted 1 hour caching options while I uploading the files to cloud storage which is I totaly forget.

I changed 1 hour to 1 min and problem solved!

await bucket
  .upload(filePath, {
    destination: key,
    gzip: true,
    metadata: {
       cacheControl: "public, max-age=60" // 1 minute caching
    },
    public: true
});
Related