Question

I've finally managed to get images to rotate properly on App Engine, now I'm struggling to get around images being cached and the standard cache busting techniques doesn't do anything.

So the first time I rotate the image, I get a different URL back and the image is rotated.

The second time I rotate it, I get the same URL back, only after appending =s300-c does the image rotate, the third time I rotate, I need to change that =s300-c to -s301-c in order to see the new image.

If I go back to =s300-c, I get the previous rotation of the image.

Appending ?datetimegoeshere doesn't work which leaves me to believe the caching is happening on Google's side and that it's not a browser problem.

What can I append to the image serving url in order to always get the latest version of the image?

I'm using the following code to write the rotated image:

GcsServiceFactory.createGcsService().delete(fileName);
GcsOutputChannel outputChannel = GcsServiceFactory.createGcsService().createOrReplace( fileName, GcsFileOptions.getDefaultInstance());
outputChannel.write(ByteBuffer.wrap(newImage.getImageData()));
outputChannel.close();

and this code to generate the new serving url:

String newImageUrl = imagesService.getServingUrl(ServingUrlOptions.Builder.withBlobKey(blobKey));

(rest of the source code posted here: Storing rotated / flipped images in Google App Engine)

This URL for example will give me one version of the image: http://lh5.ggpht.com/bbZLUGp07DJNdnkN-ezjO5Gu2hSTMIMWXnRkFJ8i9buEBpjMDHMOxviwuJIIS96mPA_2tYTUbokVY16oNwzrt4g0_7Q=s505-c

enter image description here

and this will return another version of the same image (even though it should be returning the same image, just with a different size): http://lh5.ggpht.com/bbZLUGp07DJNdnkN-ezjO5Gu2hSTMIMWXnRkFJ8i9buEBpjMDHMOxviwuJIIS96mPA_2tYTUbokVY16oNwzrt4g0_7Q=s504-c

enter image description here

How do I get Google App Engine to serve the latest version of the image?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top