Google App Engine - 破解服务网址缓存 [英] Google App Engine - Busting Serving URL Cache

查看:152
本文介绍了Google App Engine - 破解服务网址缓存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我终于设法让图片在App Engine上正确旋转,现在我正在努力绕过缓存的图片,而标准缓存清除技术无法做任何事情。



因此,当我第一次旋转图片时,我得到了一个不同的URL并且图片被旋转了。



第二次旋转时,我只有在追加= s300-c图像旋转后,第三次旋转时,我需要将= s300-c更改为-s301-c才能看到新图像。



如果我回到= s300-c,我得到图像的上一次旋转。



添加?datetimegoeshere doesn'这让我相信Google的缓存正在发生,而且这不是浏览器问题。



我可以追加图片服务网址以便始终获取图像的最新版本?



我使用以下代码编写旋转图像:

  GcsServiceFactory.createGcsService()删除(文件名)。 
GcsOutputChannel outputChannel = GcsServiceFactory.createGcsService()。createOrReplace(fileName,GcsFileOptions.getDefaultInstance());
outputChannel.write(ByteBuffer.wrap(newImage.getImageData()));
outputChannel.close();

以及此代码来生成新的投放网址:

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

(其他源代码发布在这里:



如何让Google App Engine提供最新版本的图片?

解决方案

虽然这并不能回答您关于缓存清除的问题,但它可能会帮助您解决问题。 b
$ b

试试这4个网址

http://lh5.ggpht.com/bbZLUGp07DJNdnkN-ezjO5Gu2hSTMIMWXnRkFJ8i9buEBpjMDHMOxviwuJIIS96mPA_2tYTUbokVY16oNwzrt4g0_7Q=s0
http://lh5.ggpht.com/bbZLUGp07DJNdnkN-ezjO5Gu2hSTMIMWXn RkFJ8i9buEBpjMDHMOxviwuJIIS96mPA_2tYTUbokVY16oNwzrt4g0_7Q = S0-R90
HTTP://lh5.ggpht。 COM / bbZLUGp07DJNdnkN-ezjO5Gu2hSTMIMWXnRkFJ8i9buEBpjMDHMOxviwuJIIS96mPA_2tYTUbokVY16oNwzrt4g0_7Q = S0-R180
HTTP:// lh5.ggpht.com/bbZLUGp07DJNdnkN-ezjO5Gu2hSTMIMWXnRkFJ8i9buEBpjMDHMOxviwuJIIS96mPA_2tYTUbokVY16oNwzrt4g0_7Q=s0-r270



即您可以即时旋转图像,而无需手动进行。

p>

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

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

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

解决方案

While this doesn't answer you question on cache busting it might help you solve your problem.

Try these 4 URLs

http://lh5.ggpht.com/bbZLUGp07DJNdnkN-ezjO5Gu2hSTMIMWXnRkFJ8i9buEBpjMDHMOxviwuJIIS96mPA_2tYTUbokVY16oNwzrt4g0_7Q=s0 http://lh5.ggpht.com/bbZLUGp07DJNdnkN-ezjO5Gu2hSTMIMWXnRkFJ8i9buEBpjMDHMOxviwuJIIS96mPA_2tYTUbokVY16oNwzrt4g0_7Q=s0-r90 http://lh5.ggpht.com/bbZLUGp07DJNdnkN-ezjO5Gu2hSTMIMWXnRkFJ8i9buEBpjMDHMOxviwuJIIS96mPA_2tYTUbokVY16oNwzrt4g0_7Q=s0-r180 http://lh5.ggpht.com/bbZLUGp07DJNdnkN-ezjO5Gu2hSTMIMWXnRkFJ8i9buEBpjMDHMOxviwuJIIS96mPA_2tYTUbokVY16oNwzrt4g0_7Q=s0-r270

i.e you can rotate your images on the fly without having to do it manually.

这篇关于Google App Engine - 破解服务网址缓存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆