1
votes

I need no caching for both already uploaded files and for files which will be uploaded in the future.

For files already uploaded, I tried using gsutil setmeta but files are still being cached

For files which will be uploaded in the future, I have not made any changes in my python code.

Python code

from google.cloud import storage

from google.cloud.storage import Blob

client = storage.Client()

bucket = client.get_bucket('my_bucket')

name = "vtt_files/test.txt"

blob = storage.Blob(name, bucket)

blob.upload_from_string("test213")

If I enter http://storage.googleapis.com/my_bucket/vtt_files/test.txt, file is cached

What should I do? Thank you very much in advance

1
Please edit the question to say how you are accessing the files and how you're observing that you're getting cached data. Please be as specific as possible - we should be able to duplicate what you're doing to reproduce the behavior. stackoverflow.com/help/minimal-reproducible-exampleDoug Stevenson
@DougStevenson done. thank you very much in advancepablofiumara
How can you tell that the files are being cached?AMC
@AMC I enter file's url and it shows old content. I use download_as_string and file contents are updatedpablofiumara
Sometimes this behavior is due to the browser, could you check if this behavior stands in Incognito mode as well?Soni Sol

1 Answers

1
votes

This code was the solution

    blob = storage.Blob(to_blob, destination_bucket)
    blob.cache_control = 'no-cache'
    result = blob.upload_from_string(string)