7
votes

Current procedure to serve image is as follows:

  1. Store image on google cloud storage
  2. Get blob_key: google.appengine.ext.blobstore.create_gs_key(filename)
  3. Get url: google.appengine.api.images.get_serving_url(blob_key,size=250,secure_url=True)

To remove the image, after retrieving the blob_key:

  1. Delete serving url: google.appengine.api.images.delete_serving_url(blob_key)
  2. Delete google cloud storage file: 'cloudstorage.delete(filename)'

Issue

The issue is that the url is still serving for an undefined amount of time, even though the underlying image does not exist on google cloud storage anymore. Most of the time the url returns 404 in ~24hrs, but have also seen 1 image still serving now (~2wks).

What are the expectations about the promptness of the delete_serving_url call? Any alternatives to delete the url faster?

1
Did you set the Cache-Control header on the object? - jterrace
I am using the GCS Client Library function (gcs.open) to create the object link, but could not specify the Cache-Control. Does it support it? - YacineAzmi
Mistake on my end, was using option as x-goog-cache-control, whereas it needed cache-control. Nevertheless, when creating the file using cloudstorage.open(filename, 'w',content_type=mimetype,options={'cache-control':'no-cache'}), and then going through the procedure described above the url still works after 1hr. Thoughts? - YacineAzmi
Does anybody know a workaround ? Please share. - gsinha

1 Answers

0
votes

I can address one of your two questions. Unfortunately, it's the less helpful one. :/

What are the expectations about the promptness of the delete_serving_url call?

Looking at the Java documentation for getServingUrl, they clearly spell out to expect it to take 24 hours, as you observed. I'm not sure why the Python documentation leaves this point out.

If you wish to stop serving the URL, delete the underlying blob key. This takes up to 24 hours to take effect.

The documentation doesn't explain why one of your images would still be serving after 2 weeks.

It is also interesting to note that they don't reference deleteServingUrl as part of the process to stop serving a blob. That suggests to me that step (1) in your process to "delete the image" is unnecessary.