Google App Engine:来自CloudStorageTools :: getImageServingUrl的网址未缓存

时间:2016-07-22 19:38:19

标签: php google-app-engine caching browser google-cloud-storage

我正在使用Google App Engine(GAE)通过CloudStorageTools :: getImageServingUrl()方法从Google云端存储(GCS)提供图像。

这会返回如下图像网址:

https://lh3.googleusercontent.com/KE4x0Ptk8GbqkCqEcdBVkLF0ZpQceXGL1oL6C5be5zHSqpEGI_pceev1SjOFTHh1kj7zbzwHcFfFgh_6gSIA=s1600

此图像未缓存在浏览器中,因为它不会返回正确的expire / cache标头。我已经尝试在GCS中设置对象的缓存标头:

Cache-control: public, max-age=1296000

...以及GAE配置文件app.yaml的缓存设置:

default_expiration: "4d 5h"

......如果提供图像,哪个展位似乎没有影响。有没有办法控制通过来自CloudStorageTools :: getImageServingUrl()方法的URL提供的图像的缓存头?

谢谢!

Ť

1 个答案:

答案 0 :(得分:0)

正如我的评论所述,这可以通过" -e31"来实现。旗帜(在这种情况下为31天)。此外,它可以通过nginx反向代理设置来实现(如果您需要对标头进行更多控制,则非常有用)。我在帖子Google App Engine getImageServingUrl with download file name中的回答显示了一个例子。

相关问题